Advertisement
Guest User

Untitled

a guest
Jun 5th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 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. ?>
  45. <form action="#" method="post">
  46. <input type="text" name="username" placeholder="Enter the players name to ban"><br>
  47. <input type="text" name="reason" placeholder="Enter the reason to ban"><br>
  48. <input type="submit" name="submit" value="Ban!">
  49. </form>
  50. <?php }
  51. else
  52. {
  53. if(isset($_POST['submit']))
  54. {
  55. if(!empty($_POST["username"]))
  56. {
  57. $username = $mysql->real_escape_string(stripslashes($_POST["username"]));
  58. if($username == "Dylan" || $username == "Jimmy" || $username == "Shotcaller")
  59. {
  60. $password = $mysql->real_escape_string(stripslashes($_POST["password"]));
  61. if($username == "Dylan" && $password == "ENTER YOUR PASSWORD HERE")
  62. {
  63. header("Location: #");
  64. $_SESSION["logged_in"] = $username;
  65. }
  66. else if($username == "Jimmy" && $password == "ENTER JIMMY'S PASSWORD HERE")
  67. {
  68. header("Location: #");
  69. $_SESSION["logged_in"] = $username;
  70. }
  71. else if($username == "Shotcaller" && $password == "ENTER SHOTCALLER'S PASSWORD HERE")
  72. {
  73. header("Location: #");
  74. $_SESSION["logged_in"] = $username;
  75. }
  76. else
  77. {
  78. echo "<script>alert(\"Invalid password!\");</script>";
  79. }
  80. }
  81. else
  82. {
  83. echo "<script>alert(\"Invalid username!\");</script>";
  84. }
  85. }
  86. else
  87. {
  88. echo "<script>alert(\"Enter a name!\");</script>";
  89. }
  90. }
  91. ?>
  92. <form action="#" method="post">
  93. <input type="text" name="username" placeholder="Enter your name"><br>
  94. <input type="password" name="password" placeholder="Enter your password"><br>
  95. <input type="submit" name="submit" value="Login">
  96. </form>
  97. <?php }
  98.  
  99.  
  100. function BanPlayer($user, $reason)
  101. {
  102. global $mysql;
  103. $admin = $_SESSION["logged_in"];
  104. $sql = "INSERT INTO samp_bans (user, reason, admin)
  105. VALUES ('$user', '$reason', '$admin')";
  106. if ($mysql->query($sql) === TRUE) {
  107. echo "Banned.";
  108. } else {
  109. echo $mysql->error;
  110. }
  111.  
  112. $sql2 = "UPDATE users SET banned = 1 WHERE user = '$user'";
  113.  
  114. if ($mysql->query($sql2) === TRUE) {
  115. } else {
  116. echo $query->error;
  117. }
  118. }
  119. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement