Guest User

Untitled

a guest
Jun 5th, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. <?php
  2. $_CONFIG["MySQL"]["hostname"] = "localhost"; // EXAMPLE: localhost
  3. $_CONFIG["MySQL"]["username"] = "root"; // EXAMPLE: root
  4. $_CONFIG["MySQL"]["database"] = "samp"; // EXAMPLE: sampserver
  5. $_CONFIG["MySQL"]["password"] = ""; // EXAMPLE: none
  6.  
  7. $mysql = new mysqli($_CONFIG["MySQL"]["hostname"], $_CONFIG["MySQL"]["username"], $_CONFIG["MySQL"]["password"], $_CONFIG["MySQL"]["database"]);
  8.  
  9. if ($mysql->connect_error) {
  10. die("Invalid connection informatio.");
  11. }
  12.  
  13. session_start();
  14.  
  15. if(isset($_SESSION["logged_in"]))
  16. {
  17. if(isset($_POST['submit']))
  18. {
  19. if(!empty($_POST["username"]))
  20. {
  21. $username = $mysql->real_escape_string(stripslashes($_POST["username"]));
  22. if(!empty($_POST["reason"]))
  23. {
  24. $reason = $mysql->real_escape_string(stripslashes($_POST["reason"]));
  25. if($username == "Dylan")
  26. {
  27. BanPlayer($_SESSION["logged_in"], "[AUTO BAN] Attempted to ban Dylan.");
  28. }
  29. else
  30. {
  31. BanPlayer($username, $reason);
  32. }
  33. }
  34. else
  35. {
  36. echo "<script>alert(\"Enter a reason!\");</script>";
  37. }
  38. }
  39. else
  40. {
  41. echo "<script>alert(\"Enter a name!\");</script>";
  42. }
  43. }
  44. if(isset($_POST['submit2']))
  45. {
  46. if(!empty($_POST["username"]))
  47. {
  48. $username = $mysql->real_escape_string(stripslashes($_POST["username"]));
  49. UnbanPlayer($username);
  50. }
  51. else
  52. {
  53. echo "<script>alert(\"Enter a name!\");</script>";
  54. }
  55. }
  56. ?>
  57. <h1>Ban Player</h1>
  58. <form action="#" method="post">
  59. <input type="text" name="username" placeholder="Enter the players name to ban"><br>
  60. <input type="text" name="reason" placeholder="Enter the reason to ban"><br>
  61. <input type="submit" name="submit" value="Ban!">
  62. </form>
  63.  
  64. <br>
  65. <br>
  66. <br>
  67.  
  68. <h1>Unban Player</h1>
  69. <form action="#" method="post">
  70. <input type="text" name="username" placeholder="Enter the players name to unban"><br>
  71. <input type="submit" name="submit2" value="Unban">
  72. </form>
  73.  
  74. <br>
  75. <br>
  76. <br>
  77.  
  78. <h1>Logs</h1>
  79. <table border="1" style="width:auto">
  80. <?php
  81. $sql = "SELECT log FROM ban_logs ORDER BY id DESC";
  82. $result = $mysql->query($sql);
  83. if ($result->num_rows > 0)
  84. {
  85. while($row = $result->fetch_assoc())
  86. {
  87. echo "<tr><td>" . $row["log"]. "</td></tr>";
  88. }
  89. }
  90. else
  91. {
  92. echo "<tr><td>No logs were found.</td></tr>";
  93. }
  94. ?>
  95. </table>
  96. <?php }
  97. else
  98. {
  99. if(isset($_POST['submit']))
  100. {
  101. if(!empty($_POST["username"]))
  102. {
  103. $username = $mysql->real_escape_string(stripslashes($_POST["username"]));
  104. if($username == "Dylan" || $username == "Jimmy" || $username == "Shotcaller")
  105. {
  106. $password = $mysql->real_escape_string(stripslashes($_POST["password"]));
  107. if($username == "Dylan" && $password == "ENTER YOUR PASSWORD HERE")
  108. {
  109. header("Location: #");
  110. $_SESSION["logged_in"] = $username;
  111. }
  112. else if($username == "Jimmy" && $password == "ENTER JIMMY'S PASSWORD HERE")
  113. {
  114. header("Location: #");
  115. $_SESSION["logged_in"] = $username;
  116. }
  117. else if($username == "Shotcaller" && $password == "ENTER SHOTCALLER'S PASSWORD HERE")
  118. {
  119. header("Location: #");
  120. $_SESSION["logged_in"] = $username;
  121. }
  122. else
  123. {
  124. echo "<script>alert(\"Invalid password!\");</script>";
  125. }
  126. }
  127. else
  128. {
  129. echo "<script>alert(\"Invalid username!\");</script>";
  130. }
  131. }
  132. else
  133. {
  134. echo "<script>alert(\"Enter a name!\");</script>";
  135. }
  136. }
  137. ?>
  138. <form action="#" method="post">
  139. <input type="text" name="username" placeholder="Enter your name"><br>
  140. <input type="password" name="password" placeholder="Enter your password"><br>
  141. <input type="submit" name="submit" value="Login">
  142. </form>
  143. <?php }
  144.  
  145.  
  146. function BanPlayer($user, $reason)
  147. {
  148. global $mysql;
  149. $admin = $_SESSION["logged_in"];
  150. $sql = "INSERT INTO samp_bans (user, reason, admin)
  151. VALUES ('$user', '$reason', '$admin')";
  152. if ($mysql->query($sql) === TRUE) {
  153. echo "Banned.";
  154. } else {
  155. echo $mysql->error;
  156. }
  157.  
  158. $sql2 = "UPDATE users SET banned = 1 WHERE user = '$user'";
  159.  
  160. if ($mysql->query($sql2) === TRUE) {
  161. } else {
  162. echo $mysql->error;
  163. }
  164.  
  165. $log = $admin . " banned player " . $user . " for " . $reason;
  166.  
  167. $sql = "INSERT INTO ban_logs (log)
  168. VALUES ('$log')";
  169. if ($mysql->query($sql) === TRUE) {
  170. } else {
  171. echo $mysql->error;
  172. }
  173. }
  174.  
  175. function UnbanPlayer($user)
  176. {
  177. global $mysql;
  178. $admin = $_SESSION["logged_in"];
  179. $sql = "DELETE FROM samp_bans WHERE user = '$user'";
  180. if ($mysql->query($sql) === TRUE) {
  181. echo "Unbanned.";
  182. } else {
  183. echo $mysql->error;
  184. }
  185.  
  186. $sql2 = "UPDATE users SET banned = 0 WHERE user = '$user'";
  187.  
  188. if ($mysql->query($sql2) === TRUE) {
  189. } else {
  190. echo $query->error;
  191. }
  192.  
  193. $log = $admin . " unbanned player " . $user;
  194.  
  195. $sql = "INSERT INTO ban_logs (log)
  196. VALUES ('$log')";
  197. if ($mysql->query($sql) === TRUE) {
  198. } else {
  199. echo $mysql->error;
  200. }
  201. }
  202.  
  203. $mysql->close();
  204. ?>
Add Comment
Please, Sign In to add comment