diff --git a/gazelle.sql b/gazelle.sql index ed3116a3..0c8166f9 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -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`), diff --git a/sections/collages/manage.php b/sections/collages/manage.php index cf9b4867..52d4540b 100644 --- a/sections/collages/manage.php +++ b/sections/collages/manage.php @@ -103,9 +103,9 @@ - - - + + + diff --git a/sections/reports/ajax_add_notes.php b/sections/reports/ajax_add_notes.php new file mode 100644 index 00000000..9ac228d6 --- /dev/null +++ b/sections/reports/ajax_add_notes.php @@ -0,0 +1,25 @@ + 'failure' + ) + ); + die(); +} + +$ID = (int) $_GET['id']; + +$Notes = str_replace("
", "\n", $_GET['notes']); +$Notes = db_string($Notes); + +$DB->query("UPDATE reports SET Notes = '$Notes' WHERE ID = '$ID'"); +print + json_encode( + array( + 'status' => 'success' + ) + ); +exit(); diff --git a/sections/reports/ajax_claim_report.php b/sections/reports/ajax_claim_report.php new file mode 100644 index 00000000..5f01ba42 --- /dev/null +++ b/sections/reports/ajax_claim_report.php @@ -0,0 +1,35 @@ + '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(); +} \ No newline at end of file diff --git a/sections/reports/index.php b/sections/reports/index.php index 20280320..d03f0cc9 100644 --- a/sections/reports/index.php +++ b/sections/reports/index.php @@ -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; diff --git a/sections/reports/reports.php b/sections/reports/reports.php index ea59f407..15d9f636 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -1,46 +1,45 @@ query('SELECT FOUND_ROWS()'); @@ -71,165 +72,182 @@ // Start printing stuff ?>
-
-

Active Reports

- -
- -next_record()) { - $Type = $Types[$Short]; - $Reference = "reports.php?id=".$ReportID."#report".$ReportID; -?> -
-
-
- - - -
- - - - - - - - - - - - - - - - - -
Report # was reported by [Contact]
- -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 "".display_str($Username).""; - } - 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 "".display_str($Name).""; - } - 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 "".display_str($Name).""; - } - 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 "".display_str($Title).""; - } - 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 "FORUM POST"; - } - 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 "REQUEST COMMENT"; - } - 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 "TORRENT COMMENT"; - } - 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 "COMMENT"; - } - break; +
+

Active Reports

- 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 "COLLAGE COMMENT"; - } - break; + +
+ + next_record()) { + $Type = $Types[$Short]; + $Reference = "reports.php?id=" . $ReportID . "#report" . $ReportID; + ?> +
+ + + + + + + + + + + + + + + + + + + + +
Report # was reported by [Contact]
+ + 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 "" . display_str($Username) . ""; + } + 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 "" . display_str($Name) . ""; + } + 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 "" . display_str($Name) . ""; + } + 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 "" . display_str($Title) . ""; + } + 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 "FORUM POST"; + } + 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 "REQUEST COMMENT"; + } + 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 "TORRENT COMMENT"; + } + 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 "COMMENT"; + } + 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 "COLLAGE COMMENT"; + } + break; + } + ?> + +
full_format($Reason)?>
+ + Claimed by + + Claim + +    + Toggle Notes + +
;"> + +
+ +
+
+ + + + + +
+ +
+
+ set_query_id($Reports); } -?> -
-
full_format($Reason)?>
- -
- -
-
-set_query_id($Reports); -} -?> - + ?> +
\r\n]?)(\r\n|\n\r|\r|\n)/g, '
'); + ajax.get('reports.php?action=add_notes&id=' + id + '¬es=' + 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 = 'Claimed by ' + username + ''; + } + }); +} +