Empty commit

This commit is contained in:
Git 2012-12-10 08:00:21 +00:00
parent 494d38fff5
commit 5625f727e8
7 changed files with 300 additions and 177 deletions

View File

@ -538,6 +538,8 @@ CREATE TABLE `reports` (
`ResolvedTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ReportedTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`Reason` text COLLATE utf8_bin NOT NULL,
`ClaimerID` int(10) unsigned NOT NULL DEFAULT '0',
`Notes` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`),
KEY `Status` (`Status`),
KEY `Type` (`Type`),

View File

@ -103,9 +103,9 @@
<input class="sort_numbers" type="text" name="sort" value="<?=$Sort?>" id="sort_<?=$GroupID?>" size="4" />
</td>
<td><?=$Number?></td>
<td><?=trim($CatNum)?></td>
<td><?=trim($GroupYear)?></td>
<td><?=trim($DisplayName)?></td>
<td><?=trim($CatNum) ?: '&nbsp;'?></td>
<td><?=trim($GroupYear) ?: '&nbsp;'?></td>
<td><?=trim($DisplayName) ?: '&nbsp;'?></td>
<td><?=trim($TorrentLink)?></td>
<td class="nobr"><?=Users::format_username($UserID, $Username, false, false, false)?></td>
<td class="nobr">

View File

@ -0,0 +1,25 @@
<?php
if (!check_perms('site_moderate_forums') || empty($_GET['id'])) {
print
json_encode(
array(
'status' => 'failure'
)
);
die();
}
$ID = (int) $_GET['id'];
$Notes = str_replace("<br />", "\n", $_GET['notes']);
$Notes = db_string($Notes);
$DB->query("UPDATE reports SET Notes = '$Notes' WHERE ID = '$ID'");
print
json_encode(
array(
'status' => 'success'
)
);
exit();

View File

@ -0,0 +1,35 @@
<?php
if (!check_perms('site_moderate_forums') || empty($_GET['id'])) {
print
json_encode(
array(
'status' => 'failure'
)
);
die();
}
$ID = (int)$_GET['id'];
$DB->query("SELECT ClaimerID FROM reports WHERE ID = '$ID'");
list($ClaimerID) = $DB->next_record();
if ($ClaimerID) {
print
json_encode(
array(
'status' => 'dupe'
)
);
exit();
} else {
$UserID = $LoggedUser['ID'];
$DB->query("UPDATE reports SET ClaimerID = '$UserID' WHERE ID = '$ID'");
print
json_encode(
array(
'status' => 'success',
'username' => $LoggedUser['Username']
)
);
exit();
}

View File

@ -24,6 +24,12 @@
case 'takecompose':
include(SERVER_ROOT.'/sections/reports/takecompose.php');
break;
case 'add_notes':
include(SERVER_ROOT.'/sections/reports/ajax_add_notes.php');
break;
case 'claim':
include(SERVER_ROOT.'/sections/reports/ajax_claim_report.php');
break;
default:
include(SERVER_ROOT.'/sections/reports/reports.php');
break;

View File

@ -1,46 +1,45 @@
<?
/************************************************************************
************************************************************************/
if(!check_perms('admin_reports') && !check_perms('project_team') && !check_perms('site_moderate_forums')) {
if (!check_perms('admin_reports') && !check_perms('project_team') && !check_perms('site_moderate_forums')) {
error(404);
}
// Number of reports per page
define('REPORTS_PER_PAGE', '10');
include(SERVER_ROOT.'/classes/class_text.php');
include(SERVER_ROOT . '/classes/class_text.php');
$Text = NEW TEXT;
list($Page,$Limit) = Format::page_limit(REPORTS_PER_PAGE);
list($Page, $Limit) = Format::page_limit(REPORTS_PER_PAGE);
include(SERVER_ROOT.'/sections/reports/array.php');
include(SERVER_ROOT . '/sections/reports/array.php');
// Header
View::show_header('Reports','bbcode');
View::show_header('Reports', 'bbcode,reports');
if($_GET['id'] && is_number($_GET['id'])) {
if ($_GET['id'] && is_number($_GET['id'])) {
$View = "Single report";
$Where = "r.ID = ".$_GET['id'];
} else if(empty($_GET['view'])) {
$Where = "r.ID = " . $_GET['id'];
} else if (empty($_GET['view'])) {
$View = "New";
$Where = "Status='New'";
} else {
$View = $_GET['view'];
switch($_GET['view']) {
switch ($_GET['view']) {
case 'old' :
$Where = "Status='Resolved'";
break;
default :
default :
error(404);
break;
}
}
if(!check_perms('admin_reports')) {
if(check_perms('project_team')) {
if (!check_perms('admin_reports')) {
if (check_perms('project_team')) {
$Where .= " AND Type = 'request_update'";
}
if(check_perms('site_moderate_forums')) {
if (check_perms('site_moderate_forums')) {
$Where .= " AND Type IN('collages_comment', 'Post', 'requests_comment', 'thread', 'torrents_comment', 'torrent_comments')";
}
@ -54,12 +53,14 @@
r.Type,
r.ReportedTime,
r.Reason,
r.Status
r.Status,
r.ClaimerID,
r.Notes
FROM reports AS r
JOIN users_main AS um ON r.UserID=um.ID
WHERE ".$Where."
WHERE " . $Where . "
ORDER BY ReportedTime
DESC LIMIT ".$Limit);
DESC LIMIT " . $Limit);
// Number of results (for pagination)
$DB->query('SELECT FOUND_ROWS()');
@ -71,165 +72,182 @@
// Start printing stuff
?>
<div class="thin">
<div class="header">
<h2>Active Reports</h2>
<div class="linkbox">
<a href="reports.php">New</a> |
<a href="reports.php?view=old">Old</a> |
<a href="reports.php?action=stats">Stats</a>
</div>
</div>
<div class="linkbox">
<?
// pagination
$Pages = Format::get_pages($Page,$Results,REPORTS_PER_PAGE,11);
echo $Pages;
?>
</div>
<?
while(list($ReportID, $SnitchID, $SnitchName, $ThingID, $Short, $ReportedTime, $Reason, $Status) = $DB->next_record()) {
$Type = $Types[$Short];
$Reference = "reports.php?id=".$ReportID."#report".$ReportID;
?>
<div id="report<?=$ReportID?>">
<form class="manage_form" name="report" action="reports.php" method="post">
<div>
<input type="hidden" name="reportid" value="<?=$ReportID?>" />
<input type="hidden" name="action" value="takeresolve" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
</div>
<table cellpadding="5" id="report_<?=$ReportID?>">
<tr>
<td><strong><a href="<?=$Reference?>">Report #<?=$ReportID?></a></strong></td>
<td><strong><?=$Type['title']?></strong> was reported by <a href="user.php?id=<?=$SnitchID?>"><?=$SnitchName?></a> <?=time_diff($ReportedTime)?> <a href="reports.php?action=compose&amp;to=<?=$SnitchID?>&amp;reportid=<?=$ReportID?>&amp;type=<?=$Short?>&amp;thingid=<?=$ThingID?>">[Contact]</a></td>
</tr>
<tr>
<td class="center" colspan="2">
<strong>
<?
switch($Short) {
case "user" :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ThingID);
if($DB->record_count() < 1) {
echo "No user with the reported ID found";
} else {
list($Username) = $DB->next_record();
echo "<a href='user.php?id=".$ThingID."'>".display_str($Username)."</a>";
}
break;
case "request" :
case "request_update" :
$DB->query("SELECT Title FROM requests WHERE ID=".$ThingID);
if($DB->record_count() < 1) {
echo "No request with the reported ID found";
} else {
list($Name) = $DB->next_record();
echo "<a href='requests.php?action=view&amp;id=".$ThingID."'>".display_str($Name)."</a>";
}
break;
case "collage" :
$DB->query("SELECT Name FROM collages WHERE ID=".$ThingID);
if($DB->record_count() < 1) {
echo "No collage with the reported ID found";
} else {
list($Name) = $DB->next_record();
echo "<a href='collages.php?id=".$ThingID."'>".display_str($Name)."</a>";
}
break;
case "thread" :
$DB->query("SELECT Title FROM forums_topics WHERE ID=".$ThingID);
if($DB->record_count() < 1) {
echo "No forum thread with the reported ID found";
} else {
list($Title) = $DB->next_record();
echo "<a href='forums.php?action=viewthread&amp;threadid=".$ThingID."'>".display_str($Title)."</a>";
}
break;
case "post" :
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
$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);
if($DB->record_count() < 1) {
echo "No forum post with the reported ID found";
} else {
list($PostID,$Body,$TopicID,$PostNum) = $DB->next_record();
echo "<a href='forums.php?action=viewthread&amp;threadid=".$TopicID."&amp;post=".$PostNum."#post".$PostID."'>FORUM POST</a>";
}
break;
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);
if($DB->record_count() < 1) {
echo "No request comment with the reported ID found";
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='requests.php?action=view&amp;id=".$RequestID."&amp;page=".$PageNum."#post".$ThingID."'>REQUEST COMMENT</a>";
}
break;
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);
if($DB->record_count() < 1) {
echo "No torrent comment with the reported ID found";
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='torrents.php?id=".$GroupID."&amp;page=".$PageNum."#post".$ThingID."'>TORRENT COMMENT</a>";
}
break;
case "artist_comment" :
$DB->query("SELECT ac.ArtistID, ac.Body, (SELECT COUNT(ID) FROM artist_comments WHERE ID <= ".$ThingID." AND artist_comments.ArtistID = ac.ArtistID) AS CommentNum FROM artist_comments AS ac WHERE ID=".$ThingID);
if($DB->record_count() < 1) {
echo "No comment with the reported ID found";
} else {
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='artist.php?id=".$ArtistID."&page=".$PageNum."#post".$ThingID."'>COMMENT</a>";
}
break;
<div class="header">
<h2>Active Reports</h2>
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);
if($DB->record_count() < 1) {
echo "No collage comment with the reported ID found";
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
echo "<a href='collage.php?action=comments&amp;collageid=".$CollageID."&amp;page=".$PageNum."#post".$ThingID."'>COLLAGE COMMENT</a>";
}
break;
<div class="linkbox">
<a href="reports.php">New</a> |
<a href="reports.php?view=old">Old</a> |
<a href="reports.php?action=stats">Stats</a>
</div>
</div>
<div class="linkbox">
<?
// pagination
$Pages = Format::get_pages($Page, $Results, REPORTS_PER_PAGE, 11);
echo $Pages;
?>
</div>
<?
while (list($ReportID, $SnitchID, $SnitchName, $ThingID, $Short, $ReportedTime, $Reason, $Status, $ClaimerID, $Notes) = $DB->next_record()) {
$Type = $Types[$Short];
$Reference = "reports.php?id=" . $ReportID . "#report" . $ReportID;
?>
<div id="report<?=$ReportID?>">
<table cellpadding="5" id="report_<?=$ReportID?>">
<tr>
<td><strong><a href="<?=$Reference?>">Report #<?=$ReportID?></a></strong></td>
<td><strong><?=$Type['title']?></strong> was reported by <a href="user.php?id=<?=$SnitchID?>"><?=$SnitchName?></a> <?=time_diff($ReportedTime)?> <a
href="reports.php?action=compose&amp;to=<?=$SnitchID?>&amp;reportid=<?=$ReportID?>&amp;type=<?=$Short?>&amp;thingid=<?=$ThingID?>">[Contact]</a></td>
</tr>
<tr>
<td class="center" colspan="2">
<strong>
<?
switch ($Short) {
case "user" :
$DB->query("SELECT Username FROM users_main WHERE ID=" . $ThingID);
if ($DB->record_count() < 1) {
echo "No user with the reported ID found";
} else {
list($Username) = $DB->next_record();
echo "<a href='user.php?id=" . $ThingID . "'>" . display_str($Username) . "</a>";
}
break;
case "request" :
case "request_update" :
$DB->query("SELECT Title FROM requests WHERE ID=" . $ThingID);
if ($DB->record_count() < 1) {
echo "No request with the reported ID found";
} else {
list($Name) = $DB->next_record();
echo "<a href='requests.php?action=view&amp;id=" . $ThingID . "'>" . display_str($Name) . "</a>";
}
break;
case "collage" :
$DB->query("SELECT Name FROM collages WHERE ID=" . $ThingID);
if ($DB->record_count() < 1) {
echo "No collage with the reported ID found";
} else {
list($Name) = $DB->next_record();
echo "<a href='collages.php?id=" . $ThingID . "'>" . display_str($Name) . "</a>";
}
break;
case "thread" :
$DB->query("SELECT Title FROM forums_topics WHERE ID=" . $ThingID);
if ($DB->record_count() < 1) {
echo "No forum thread with the reported ID found";
} else {
list($Title) = $DB->next_record();
echo "<a href='forums.php?action=viewthread&amp;threadid=" . $ThingID . "'>" . display_str($Title) . "</a>";
}
break;
case "post" :
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
$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);
if ($DB->record_count() < 1) {
echo "No forum post with the reported ID found";
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
echo "<a href='forums.php?action=viewthread&amp;threadid=" . $TopicID . "&amp;post=" . $PostNum . "#post" . $PostID . "'>FORUM POST</a>";
}
break;
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);
if ($DB->record_count() < 1) {
echo "No request comment with the reported ID found";
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='requests.php?action=view&amp;id=" . $RequestID . "&amp;page=" . $PageNum . "#post" . $ThingID . "'>REQUEST COMMENT</a>";
}
break;
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);
if ($DB->record_count() < 1) {
echo "No torrent comment with the reported ID found";
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='torrents.php?id=" . $GroupID . "&amp;page=" . $PageNum . "#post" . $ThingID . "'>TORRENT COMMENT</a>";
}
break;
case "artist_comment" :
$DB->query("SELECT ac.ArtistID, ac.Body, (SELECT COUNT(ID) FROM artist_comments WHERE ID <= " . $ThingID . " AND artist_comments.ArtistID = ac.ArtistID) AS CommentNum FROM artist_comments AS ac WHERE ID=" . $ThingID);
if ($DB->record_count() < 1) {
echo "No comment with the reported ID found";
} else {
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href='artist.php?id=" . $ArtistID . "&page=" . $PageNum . "#post" . $ThingID . "'>COMMENT</a>";
}
break;
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);
if ($DB->record_count() < 1) {
echo "No collage comment with the reported ID found";
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
echo "<a href='collage.php?action=comments&amp;collageid=" . $CollageID . "&amp;page=" . $PageNum . "#post" . $ThingID . "'>COLLAGE COMMENT</a>";
}
break;
}
?>
</strong>
</td>
</tr>
<tr>
<td colspan="2"><?=$Text->full_format($Reason)?></td>
</tr>
<tr>
<td colspan="2">
<? if ($ClaimerID) { ?>
Claimed by <?=Users::format_username($ClaimerID, false, false, false, false)?>
<? } else { ?>
<a href="#" id="claim_<?=$ReportID?>" onclick="claim(<?=$ReportID?>); return false;"; return false;">Claim</a>
<? } ?>
&nbsp;&nbsp;
<a onclick="toggleNotes(<?=$ReportID?>); return false;" href="#">Toggle Notes</a>
<div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? "none" : "block"?>;">
<textarea cols="50" rows="3" id="notes_<?=$ReportID?>"><?=$Notes?></textarea>
<br/>
<input type="submit" onclick="saveNotes(<?=$ReportID?>)" value="Save"/>
</div>
</td>
</tr>
<? if ($Status != "Resolved") { ?>
<tr>
<td class="center" colspan="2">
<form class="manage_form" name="report" action="reports.php" method="post">
<input type="hidden" name="reportid" value="<?=$ReportID?>"/>
<input type="hidden" name="action" value="takeresolve"/>
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>"/>
<input type="submit" name="submit" value="Resolve"/>
</td>
</tr>
<? } ?>
</table>
</form>
</div>
<br/>
<?
$DB->set_query_id($Reports);
}
?>
</strong>
</td>
</tr>
<tr>
<td colspan="2"><?=$Text->full_format($Reason)?></td>
</tr>
<? if($Status != "Resolved") { ?>
<tr>
<td class="center" colspan="2">
<input type="submit" name="submit" value="Resolve" />
</td>
</tr>
<? } ?>
</table>
</form>
</div>
<br />
<?
$DB->set_query_id($Reports);
}
?>
<div class="linkbox">
<?
echo $Pages;
?>
</div>
?>
<div class="linkbox">
<?
echo $Pages;
?>
</div>
</div>
<?
View::show_footer();

View File

@ -0,0 +1,37 @@
function toggleNotes(id) {
var style = $('#notes_div_' + id).raw().style.display;
if (style == "none") {
$('#notes_div_' + id).raw().style.display = "block";
}
else {
$('#notes_div_' + id).raw().style.display = "none";
}
}
function saveNotes(id) {
var notes = $('#notes_' + id).raw().value;
notes = notes.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
ajax.get('reports.php?action=add_notes&id=' + id + '&notes=' + notes, function (response) {
if (JSON.parse(response)['status'] != 'success') {
alert("Error, could not save notes");
}
});
}
function claim(id) {
ajax.get('reports.php?action=claim&id=' + id, function (response) {
var json = JSON.parse(response);
if (json['status'] == 'failure') {
alert("Error, could not claim.");
}
if (json['status'] == 'dupe') {
alert("Oops, this report has already been claimed.");
}
if (json['status'] == 'success') {
var username = json['username'];
$('#claim_' + id).raw().innerHTML = '<a href="#" onclick="return false;">Claimed by ' + username + '</a>';
}
});
}