Gazelle/sections/reports/compose.php

231 lines
6.6 KiB
PHP
Raw Normal View History

2012-09-04 08:00:23 +00:00
<?
2013-05-01 08:00:16 +00:00
if (!check_perms('site_moderate_forums')) {
2012-09-04 08:00:23 +00:00
error(403);
}
2013-05-01 08:00:16 +00:00
if (empty($Return)) {
2012-09-04 08:00:23 +00:00
$ToID = $_GET['to'];
2013-05-01 08:00:16 +00:00
if ($ToID == $LoggedUser['ID']) {
2012-09-04 08:00:23 +00:00
error("You cannot start a conversation with yourself!");
header('Location: inbox.php');
}
}
2013-05-01 08:00:16 +00:00
if (!$ToID || !is_number($ToID)) {
2012-09-04 08:00:23 +00:00
error(404);
}
$ReportID = $_GET['reportid'];
$Type = $_GET['type'];
$ThingID= $_GET['thingid'];
2013-05-01 08:00:16 +00:00
if (!$ReportID || !is_number($ReportID) || !$ThingID || !is_number($ThingID) || !$Type) {
2012-09-04 08:00:23 +00:00
error(403);
}
2013-05-01 08:00:16 +00:00
if (!empty($LoggedUser['DisablePM']) && !isset($StaffIDs[$ToID])) {
2012-09-04 08:00:23 +00:00
error(403);
}
2013-05-30 08:00:30 +00:00
$DB->query("
SELECT Username
FROM users_main
WHERE ID='$ToID'");
2012-09-18 08:00:29 +00:00
list($ComposeToUsername) = $DB->next_record();
2013-05-01 08:00:16 +00:00
if (!$ComposeToUsername) {
2012-09-04 08:00:23 +00:00
error(404);
}
2012-10-11 08:00:15 +00:00
View::show_header('Compose', 'inbox,bbcode');
2012-09-04 08:00:23 +00:00
2013-01-16 08:00:31 +00:00
// $TypeLink is placed directly in the <textarea> when composing a PM
2013-05-01 08:00:16 +00:00
switch ($Type) {
2013-05-30 08:00:30 +00:00
case 'user':
$DB->query("
SELECT Username
FROM users_main
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No user with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($Username) = $DB->next_record();
2013-05-30 08:00:30 +00:00
$TypeLink = "the user [user]{$Username}[/user]";
$Subject = 'User Report: '.display_str($Username);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'request':
case 'request_update':
$DB->query("
SELECT Title
FROM requests
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No request with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($Name) = $DB->next_record();
2013-05-30 08:00:30 +00:00
$TypeLink = 'the request [url=https://'.SSL_SITE_URL."/requests.php?action=view&amp;id=$ThingID]".display_str($Name).'[/url]';
$Subject = 'Request Report: '.display_str($Name);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'collage':
$DB->query("
SELECT Name
FROM collages
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No collage with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($Name) = $DB->next_record();
2013-05-30 08:00:30 +00:00
$TypeLink = 'the collage [url=https://'.SSL_SITE_URL."/collage.php?id=$ThingID]".display_str($Name).'[/url]';
$Subject = 'Collage Report: '.display_str($Name);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'thread':
$DB->query("
SELECT Title
FROM forums_topics
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No forum thread with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($Title) = $DB->next_record();
2013-05-30 08:00:30 +00:00
$TypeLink = 'the forum thread [url=https://'.SSL_SITE_URL."/forums.php?action=viewthread&amp;threadid=$ThingID]".display_str($Title).'[/url]';
$Subject = 'Forum Thread Report: '.display_str($Title);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'post':
2012-09-04 08:00:23 +00:00
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
2013-05-30 08:00:30 +00:00
$DB->query("
SELECT
p.ID,
p.Body,
p.TopicID,
( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID<=p.ID
) AS PostNum
FROM forums_posts AS p
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No forum post with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
2013-05-30 08:00:30 +00:00
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
$TypeLink = 'this [url=https://'.SSL_SITE_URL."/forums.php?action=viewthread&amp;threadid=$TopicID&amp;post=$PostNum#post$PostID]forum post[/url]";
$Subject = 'Forum Post Report: Post ID #'.display_str($PostID);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'requests_comment':
$DB->query("
SELECT
rc.RequestID,
rc.Body,
( SELECT COUNT(ID)
FROM requests_comments
WHERE ID <= $ThingID
AND requests_comments.RequestID = rc.RequestID
) AS CommentNum
FROM requests_comments AS rc
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No request comment with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
2013-05-30 08:00:30 +00:00
$TypeLink = 'this [url=https://'.SSL_SITE_URL."/requests.php?action=view&amp;id=$RequestID&amp;page=$PageNum#post$ThingID]request comment[/url]";
$Subject = 'Request Comment Report: ID #'.display_str($ThingID);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'torrents_comment':
$DB->query("
SELECT
tc.GroupID,
tc.Body,
( SELECT COUNT(ID)
FROM torrents_comments
WHERE ID <= $ThingID
AND torrents_comments.GroupID = tc.GroupID
) AS CommentNum
FROM torrents_comments AS tc
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No torrent comment with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
2013-05-30 08:00:30 +00:00
$TypeLink = 'this [url=https://'.SSL_SITE_URL."/torrents.php?id=$GroupID&amp;page=$PageNum#post$ThingID]torrent comment[/url]";
$Subject = 'Torrent Comment Report: ID #'.display_str($ThingID);
2012-09-04 08:00:23 +00:00
}
break;
2013-05-30 08:00:30 +00:00
case 'collages_comment':
$DB->query("
SELECT
cc.CollageID,
cc.Body,
( SELECT COUNT(ID)
FROM collages_comments
WHERE ID <= $ThingID
AND collages_comments.CollageID = cc.CollageID
) AS CommentNum
FROM collages_comments AS cc
WHERE ID=$ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-30 08:00:30 +00:00
$Error = 'No collage comment with the reported ID found';
2012-09-04 08:00:23 +00:00
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
2013-05-30 08:00:30 +00:00
$TypeLink = 'this [url=https://'.SSL_SITE_URL."/collage.php?action=comments&amp;collageid=$CollageID&amp;page=$PageNum#post$ThingID]collage comment[/url]";
$Subject = 'Collage Comment Report: ID #'.display_str($ThingID);
2012-09-04 08:00:23 +00:00
}
break;
default:
2013-05-30 08:00:30 +00:00
error('Incorrect type');
2012-09-04 08:00:23 +00:00
break;
}
2013-05-01 08:00:16 +00:00
if (isset($Error)) {
2012-09-04 08:00:23 +00:00
error($Error);
}
2013-05-30 08:00:30 +00:00
$DB->query("
SELECT r.Reason
FROM reports AS r
WHERE r.ID = $ReportID");
2012-09-04 08:00:23 +00:00
list($Reason) = $DB->next_record();
2013-05-30 08:00:30 +00:00
$Body = "You reported $TypeLink for the reason:\n[quote]{$Reason}[/quote]";
2012-09-04 08:00:23 +00:00
?>
<div class="thin">
<div class="header">
<h2>
2012-09-18 08:00:29 +00:00
Send a message to <a href="user.php?id=<?=$ToID?>"> <?=$ComposeToUsername?></a>
2012-09-04 08:00:23 +00:00
</h2>
</div>
2012-09-15 08:00:25 +00:00
<form class="send_form" name="message" action="reports.php" method="post" id="messageform">
2012-09-04 08:00:23 +00:00
<div class="box pad">
2013-01-16 08:00:31 +00:00
<input type="hidden" name="action" value="takecompose" />
<input type="hidden" name="toid" value="<?=$ToID?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
2012-09-04 08:00:23 +00:00
<div id="quickpost">
<h3>Subject</h3>
2013-01-16 08:00:31 +00:00
<input type="text" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" />
<br />
2012-09-04 08:00:23 +00:00
<h3>Body</h3>
<textarea id="body" name="body" cols="95" rows="10"><?=(!empty($Body) ? $Body : '')?></textarea>
</div>
<div id="preview" class="hidden"></div>
<div id="buttons" class="center">
2013-01-16 08:00:31 +00:00
<input type="button" value="Preview" onclick="Quick_Preview();" />
<input type="submit" value="Send message" />
2012-09-04 08:00:23 +00:00
</div>
</div>
</form>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2012-09-04 08:00:23 +00:00
?>