Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

takereport.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?
  2. authorize();
  3. if (empty($_POST['id']) || !is_number($_POST['id']) || empty($_POST['type']) || ($_POST['type'] !== 'request_update' && empty($_POST['reason']))) {
  4. error(404);
  5. }
  6. include(SERVER_ROOT.'/sections/reports/array.php');
  7. if (!array_key_exists($_POST['type'], $Types)) {
  8. error(403);
  9. }
  10. $Short = $_POST['type'];
  11. $Type = $Types[$Short];
  12. $ID = $_POST['id'];
  13. if ($Short === 'request_update') {
  14. if (empty($_POST['year']) || !is_number($_POST['year'])) {
  15. error('Year must be specified.');
  16. header("Location: reports.php?action=report&type=request_update&id=$ID");
  17. die();
  18. }
  19. $Reason = '[b]Year[/b]: '.$_POST['year'].".\n\n";
  20. // If the release type is somehow invalid, return "Not given"; otherwise, return the release type.
  21. $Reason .= '[b]Release type[/b]: '.((empty($_POST['releasetype']) || !is_number($_POST['releasetype']) || $_POST['releasetype'] === '0') ? 'Not given' : $ReleaseTypes[$_POST['releasetype']]).". \n\n";
  22. $Reason .= '[b]Additional comments[/b]: '.$_POST['comment'];
  23. } else {
  24. $Reason = $_POST['reason'];
  25. }
  26. switch ($Short) {
  27. case 'request':
  28. case 'request_update':
  29. $Link = "requests.php?action=view&id=$ID";
  30. break;
  31. case 'user':
  32. $Link = "user.php?id=$ID";
  33. break;
  34. case 'collage':
  35. $Link = "collages.php?id=$ID";
  36. break;
  37. case 'thread':
  38. $Link = "forums.php?action=viewthread&threadid=$ID";
  39. break;
  40. case 'post':
  41. $DB->query("
  42. SELECT
  43. p.ID,
  44. p.TopicID,
  45. (
  46. SELECT COUNT(p2.ID)
  47. FROM forums_posts AS p2
  48. WHERE p2.TopicID = p.TopicID
  49. AND p2.ID <= p.ID
  50. ) AS PostNum
  51. FROM forums_posts AS p
  52. WHERE p.ID = $ID");
  53. list($PostID, $TopicID, $PostNum) = $DB->next_record();
  54. $Link = "forums.php?action=viewthread&threadid=$TopicID&post=$PostNum#post$PostID";
  55. break;
  56. case 'comment':
  57. $Link = "comments.php?action=jump&postid=$ID";
  58. break;
  59. }
  60. $DB->query('
  61. INSERT INTO reports
  62. (UserID, ThingID, Type, ReportedTime, Reason)
  63. VALUES
  64. ('.db_string($LoggedUser['ID']).", $ID, '$Short', '".sqltime()."', '".db_string($Reason)."')");
  65. $ReportID = $DB->inserted_id();
  66. $Channels = array();
  67. if ($Short === 'request_update') {
  68. $Channels[] = '#requestedits';
  69. $Cache->increment('num_update_reports');
  70. }
  71. if (in_array($Short, array('comment', 'post', 'thread'))) {
  72. $Channels[] = '#forumreports';
  73. }
  74. foreach ($Channels as $Channel) {
  75. send_irc("PRIVMSG $Channel :$ReportID - ".$LoggedUser['Username']." just reported a $Short: ".site_url()."$Link : ".strtr($Reason, "\n", ' '));
  76. }
  77. $Cache->delete_value('num_other_reports');
  78. header("Location: $Link");
  79. ?>