Report & Warn Script


First off you will want to run the following in phpMyAdmin

PHP Code
  1. CREATE TABLE `reps` (
  2. `id` INT( 11 ) NOT NULL auto_increment,
  3. `username` VARCHAR( 255 ) NOT NULL,
  4. `reason` TEXT NOT NULL,
  5. `date` VARCHAR( 255 ) NOT NULL,
  6. `reported_by` VARCHAR( 255 ) NOT NULL,
  7. PRIMARY KEY(`id`)
  8. );
  9.  
  10. CREATE TABLE warnings (
  11. `id` INT( 11 ) NOT NULL auto_increment,
  12. `user` VARCHAR( 255 ) NOT NULL,
  13. `reason` TEXT NOT NULL,
  14. `from` VARCHAR( 255 ) NOT NULL,
  15. `date` VARCHAR( 255 ) NOT NULL,
  16. PRIMARY KEY(`id`)
  17. );


Next, call this file report.php
PHP Code
  1. <?php
  2. if(!$logged['username']){//check for logged username
  3. print "<h2>Error</h2>
  4. <p>
  5. You Are Not Logged In
  6. </p>"; //they aren't so give err
  7. }else{ //or
  8. if(!$_POST['report']){ //form wasn't submitted
  9. print "<h2>Report User</h2>
  10. <form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
  11. <p>
  12. <label>Username</label>
  13. <input type=\"text\" name=\"user\" size=\"30\" />
  14. <label>Reason</label>
  15. <textarea cols=\"25\" rows=\"5\" name=\"reason\"></textarea>
  16. <input type=\"submit\" name=\"report\" value=\"Report User\" />
  17. </p>
  18. </form>"; //give the form to report someone :)
  19. }else{ //or...
  20. $user = protect($_POST['user']); //protect the username being reported
  21. $reason = protect($_POST['reason']); //protect the text input again
  22. $date = date("d-m-y h:i A"); //today's date
  23. $from = $logged['username']; //logged user :)
  24. if(empty($user) || empty($reason)){ //something was empty!!!!
  25. print "<h2>Error</h2>
  26. <p>
  27. You Must Fill Out The Form Completely
  28. </p>"; //haha you fail!
  29. }else{ //or not?
  30. $insert = mysql_query("INSERT INTO `reps` (`username`,`reason`,`date`,`reported_by`) VALUES ( '$user','$reason','$date','$from');"); //insert the data
  31. if(mysql_error()){ //poo theres an error
  32. print "<h2>Error</h2>
  33. <p>" . mysql_error() . "</p>"; //echo the error
  34. }else{ //or...
  35. print "<h2>Success</h2>
  36. <p>
  37. Report Sent!
  38. </p>"; //no error
  39. } //end error check
  40. } //end empty check
  41. }//end form check
  42. } //end logged in check
  43. ?>


Thats that read the comments and such :P
this next file is called repcp.php and its accessible by mods and admins.

PHP Code
  1. <?php
  2. if(!$logged['username']){ //check logged user
  3. print "<h2>Error</h2>
  4. <p>
  5. You Are Not Logged In!
  6. </p>"; //nope
  7. }elseif($logged['username'] && $logged['userlevel'] < '4'){ //not an admin or mod
  8. print "<h2>Error</h2>
  9. <p>
  10. You Do Not Have Access to this Function.
  11. </p>"; //give error >:|
  12. }else{ //or they are :D
  13. switch($_GET['x']){ //make multiple pages
  14. default: //default
  15. $get_reps = mysql_query("SELECT * FROM `reps` ORDER BY `id` DESC"); //get all reports
  16. if(mysql_num_rows($get_reps) == 0){ //none >:(
  17. print "<h2>No Reports</h2>
  18. <p>
  19. There are No Reports in the Database.
  20. </p>"; //woohoo error!!
  21. }else{ //or not >)
  22. print "<table width=\"500\">
  23. <tr>
  24. <td align=\"left\" valign=\"middle\">
  25. <b>User</b>
  26. </td>
  27. <td align=\"left\" valign=\"middle\">
  28. <b>Reported By</b>
  29. </td>
  30. <td align=\"left\" valign=\"middle\">
  31. <b>Reason</b>
  32. </td>
  33. <td align=\"left\" valign=\"middle\">
  34. <b>Date Sent</b>
  35. </td>
  36. <td align=\"center\" valign=\"middle\">
  37. <b>Options</b>
  38. </td>
  39. </tr>"; //table headers
  40. while($reps = mysql_fetch_array($get_reps)){ //make a loop for the reports to be shown
  41. print "<tr>
  42. <td align=\"left\" valign=\"middle\">
  43. $reps[username]
  44. </td>
  45. <td align=\"left\" valign=\"middle\">
  46. $reps[reported_by]
  47. </td>
  48. <td align=\"left\" valign=\"middle\">
  49. $reps[reason]
  50. </td>
  51. <td align=\"left\" valign=\"middle\">
  52. $reps[date]
  53. </td>
  54. <td align=\"center\" valign=\"middle\">
  55. <a href=\"repcp.php?x=warn&id=$reps[id]\">Warn $reps[username]</a>&nbsp;||&nbsp;
  56. <a href=\"repcp.php?x=delete&id=$reps[id]\">Delete Report</a>
  57. </td>
  58. </tr>"; //yay for data to be shown :)
  59. } //end the loop :(
  60. } //end the reports check
  61. break; //end the default page
  62. case 'warn': //haha i get to warn the dude >:)
  63. $id = (int) addslashes($_GET['id']); //make the ID Safe
  64. if(!$id){ //no id sucker!
  65. print "<h2>Error</h2>
  66. <p>
  67. No ID Selected
  68. </p>"; //haha you got an error
  69. }else{ //or not :(
  70. $check = mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check to make sure
  71. if(mysql_num_rows($check) == 0){ //lol you still got an error >:)
  72. print "<h2>Error</h2>
  73. <p>
  74. Invalid ID Selected.
  75. </p>"; //give him/her what they came for!
  76. }else{ //or not...
  77. $array = mysql_fetch_array($check); //array the data
  78. if(!$_POST['warn']){ //warn form wasn't submitted
  79. print "<h2>Warn $array[username]</h2>
  80. <form method=\"post\" action=\"$_SERVER[PHP_SELF]?x=warn&id=$id\">
  81. <p>
  82. <label>Reason</label>
  83. <textarea rows=\"5\" cols=\"25\" name=\"reason\"></textarea>
  84. <input type=\"submit\" name=\"warn\" value=\"Warn $array[username]\">
  85. </p>
  86. </form>"; //give the reasoning form :)
  87. }else{ //chyea the form was submitted
  88. $reason = protect($_POST['reason'])); //make the reason safe
  89. $date = date("m-d-y h:i A"); //the date
  90. $from = $logged['username']; //who warned
  91. if(empty($reason)){ //reason was empty
  92. print "<h2>Error</h2>
  93. <p>
  94. You Must Give A Reason
  95. </p>"; //lol you got an error
  96. }else{ //darn. your not.
  97. $insert = mysql_query("INSERT INTO `warns` (`user`,`reason`,`from`,`date`) VALUES ('$array[username]','$reason','$from','$date');"); //warn the user
  98. $delete = mysql_query("DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report
  99. if(!mysql_error()){ //no mySQL Error
  100. print "<h2>Success</h2>
  101. <p>
  102. $array[user] Has Been Warned!
  103. </p>"; //yay they were warned!
  104. }else{ //or not
  105. print "<h2>Error</h2>
  106. <p>
  107. ".mysql_error()."
  108. </p>"; //HAHA YOU GOT AN ERROR
  109. } //end error check
  110. } //end empty form check
  111. } //end the form submit check
  112. } //end the verification check
  113. } //end the final check if id is there or not xD
  114. break;
  115. case 'delete': //the delete report page >:)
  116. $id = (int) addslashes($_GET['id']); //make the ID safe
  117. if(!$id){ //no id HAHA
  118. print "<h2>Error</h2>
  119. <p>
  120. No ID Selected
  121. </p>"; //lol you got an error
  122. }else{ //there was an id D:
  123. $check = mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check DB for ID
  124. if(mysql_num_rows($check) == 0){ //haha not found
  125. print "<h2>Error</h2>
  126. <p>
  127. Invalid ID Selected
  128. </p>"; //invalid ID
  129. }else{ //its found :) :(
  130. $delete = mysql_query("DELETE FROM `reps` WHERE `id` = '$id';"); //delete it
  131. if(!mysql_error()){ //no error
  132. print "<h2>Success</h2>
  133. <p>
  134. Report Deleted
  135. </p>"; //yay!!
  136. }else{ //or not....
  137. print "<h2>Error</h2>
  138. <p>
  139. ".mysql_error()."
  140. </p>"; //you got an error
  141. } //end error check
  142. } //end verification check
  143. } //end first id check
  144. break; //end the page
  145. }//end the switch function
  146. } //end logged username check
  147. ?>


WOOHOO okay we got all that but you cant view your warns :(

call this file: my_warns.php and type something like the following.

PHP Code
  1. <?php
  2. if(!$logged['username']){ //not logged in
  3. print "<h2>Error</h2>
  4. <p>
  5. You Are not Logged In
  6. </p>"; //lol error
  7. }else{ //or they are
  8. print "<h2>Your Warnings</h2>
  9. <table width=\"400\">
  10. <tr>
  11. <td align=\"left\" valign=\"middle\">
  12. <b>Warned By</b>
  13. </td>
  14. <td align=\"left\" valign=\"middle\">
  15. <b>Reason</b>
  16. </td>
  17. <td align=\"left\" valign=\"middle\">
  18. <b>Date Warned</b>
  19. </td>
  20. </tr>"; //table headers
  21. $get_warns = mysql_query("SELECT * FROM `warns` WHERE `user` = '$logged[username]';"); //get the users warns
  22. while($warns = mysql_fetch_array($get_warns)){ //loop them
  23. print "<tr>
  24. <td align=\"left\" valign=\"middle\">
  25. $warns[from]
  26. </td>
  27. <td align=\"left\" valign=\"middle\">
  28. $warns[reason]
  29. </td>
  30. <td align=\"left\" valign=\"middle\">
  31. $warns[date]
  32. </td>
  33. </tr>"; //display their warns
  34. } //end loop
  35. print " </table>"; //end table
  36. }
  37. ?>


Thats that!

Next part will have the user jail( by darklight ) and the user banning.
ShadowMage's Avatar
Author:
Views:
4,836
Rating:
Posted on Saturday 12th September 2015 at 05:24 PM
deathwish
deathwish's Avatar
ops sorry for double post. the post didn't show up so i thought my net was giving issues
Posted on Saturday 12th September 2015 at 05:23 PM
deathwish
deathwish's Avatar
Code
$delete = mysqli_query($db,"DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report

should actually be:
Code
$delete = mysqli_query($db,"DELETE FROM `repcps` WHERE `id` = '$id';"); //delete the report
Posted on Saturday 12th September 2015 at 05:23 PM
deathwish
deathwish's Avatar
Code
$delete = mysqli_query($db,"DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report

should actually be:
Code
$delete = mysqli_query($db,"DELETE FROM `repcps` WHERE `id` = '$id';"); //delete the report
Posted on Friday 1st August 2008 at 09:34 AM
jambomb
jambomb's Avatar
hmm
Posted on Tuesday 15th July 2008 at 07:05 PM
UrbanTwitch
UrbanTwitch's Avatar
Error

You Are Not Logged In!

I am logged in actually...
Posted on Tuesday 15th July 2008 at 07:04 PM
UrbanTwitch
UrbanTwitch's Avatar
Parse error: syntax error, unexpected ')' in /home/jsfdan/public_html/repcp.php on line 88

:
Posted on Thursday 26th June 2008 at 02:16 AM
ShadowMage
ShadowMage's Avatar
nevermind. I can't access the ACP. :P
Posted on Thursday 26th June 2008 at 02:15 AM
ShadowMage
ShadowMage's Avatar
erm... i messed up. i'll update my code.
Posted on Wednesday 25th June 2008 at 09:04 PM
dtnet
dtnet's Avatar
My doesn't add reported by. It's adding all of the other fields, but not that one.
Posted on Wednesday 16th April 2008 at 02:47 PM
Nathan
Nathan's Avatar
doesnt send the reports