Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Modal edit user -->
- <div class="modal fade" id="editmodal" tabindex="-1" role="dialog" aria-labelledby="editmodal">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- <h4 class="modal-title" id="myModalLabel">Edit user</h4>
- </div>
- <div class="modal-body">
- <?php
- echo "<table class='table table-hover'>
- <tr><td>
- Unable to retrieve user.
- </td></tr>
- <tr><td>
- <img src='$_POST[whoavatar]'> <b>$_POST[whouser]</b>
- </td></tr>
- <tr><td>
- Status:
- ";
- if ($_POST[whopermission] == 0) {
- echo "User";
- }
- if ($_POST[whopermission] == 1) {
- echo "<b>Streamer</b>";
- }
- if ($_POST[whopermission] == 2) {
- echo "<b>VIP</b>";
- }
- if ($_POST[whopermission] == 3) {
- echo "<b>Designer</b>";
- }
- if ($_POST[whopermission] == 4) {
- echo "<b>Operator</b>";
- }
- if ($_POST[whopermission] == 5) {
- echo "<b>Moderator</b>";
- }
- if ($_POST[whopermission] == 6) {
- echo "<b>Administrator</b>";
- }
- if ($_POST[whopermission] == 7) {
- echo "<b>Owner</b>";
- }
- echo "</td></tr>";
- echo "
- <tr><td>
- Coins: $_POST[whocoins]
- </td></tr>
- <tr><td>
- Bets: $_POST[whobets]
- </td></tr>
- <tr><td>
- SteamID64: $_POST[who]
- </td></tr>
- <br>
- <br>
- </table>
- ";
- ?>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- <button type="button" class="btn btn-primary">Save changes</button>
- </div>
- </div>
- </div>
- </div>
- <style>
- <?php
- // For later use. This will make the forms (ban, unban, edit buttons) in the table to stay at one line.
- /* form, table {
- display:inline;
- }
- .table-hover td{
- background:#eee;
- vertical-align:top;
- border-bottom:1px solid #444;
- }
- .table-hover p{
- vertical-align:top;
- position:relative;
- overflow:hidden;
- max-height:1.3em;
- transition: max-height 0.4s;
- }
- .table-hover tr:hover p{
- max-height:100px; /* don't exagerate :)
- }
- */
- ?>
- form, table {
- display:inline;
- }
- </style>
- <?php
- //The commented lines are already in "login.php" - it's easier that way
- //if(!isset($_SESSION['steamid'])) {
- // echo "<div style='margin: 30px auto; text-align: center;'>Please login to play!<br>";
- // loginbutton();
- // echo "</div>";
- // } else {
- //include "sql.php";
- //Make sure the user cannot access this page without being an administrator
- //Connect to database with these credentials
- include "sql.php";
- // Store steamid in easier variable
- $steamid = $_SESSION['steamid'];
- //Connect, or return error if failed
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //If ban button is pressed, run the bansqlquery.
- if (isset($_POST['banuser'])) {
- //Ban SQL query.
- $banuser = mysqli_query($conn, "UPDATE users
- SET ban = '1'
- WHERE steamid = '$_POST[who]';");
- echo "
- <div class='alert alert-success' role='alert'>
- <span class='glyphicon glyphicon-ok-sign' aria-hidden='true'></span>
- You have used the banhammer on <strong>" . strip_tags($_POST[whouser]) . " ($_POST[who]) </strong>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- </div>";
- }
- //If unban button is pressed, run the unansqlquery.
- if (isset($_POST['unbanuser'])) {
- //Ban SQL query.
- $banuser = mysqli_query($conn, "UPDATE users
- SET ban = '0'
- WHERE steamid = '$_POST[who]';");
- echo "
- <div class='alert alert-success' role='alert'>
- <span class='glyphicon glyphicon-ok-sign' aria-hidden='true'></span>
- You have used the unbanhammer on <strong>" . strip_tags($_POST[whouser]) . " ($_POST[who]) </strong>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- </div>";
- }
- $selectusr = mysqli_query($conn, "SELECT * FROM `users` WHERE steamid='$steamid'");
- $num_rows_usr = mysqli_num_rows($selectusr);
- $result = $selectusr;
- if ($num_rows_usr > 0) {
- while($row = mysqli_fetch_assoc($result)) {
- $_SESSION['permissionset'] = $row['permissionset'];
- }
- }
- if ($_SESSION['permissionset'] == 0) {
- echo "<div class='alert alert-danger' role='alert' style='margin: 30px auto; text-align: center;'><span class='glyphicon glyphicon-ban-circle' aria-hidden='true'></span> You do not have access to the control panel!</div><br>";
- }
- else {
- echo "<br><span style='float:left; margin-right: 100px;'>";
- echo "<br><img src='$steamprofile[avatar]'> Welcome to the control panel. <b> $steamprofile[personaname]</b>!<br>";
- if ($_SESSION['permissionset'] == 1) {
- echo "You are a streamer, and can only view the player list. You are not allowed to edit or ban users.";
- }
- if ($_SESSION['permissionset'] == 2) {
- echo "You have VIP permissions. You are not allowed to edit or ban users.";
- }
- if ($_SESSION['permissionset'] == 3) {
- echo "You have designer permissions. You are not allowed to edit or ban users.";
- }
- if ($_SESSION['permissionset'] == 4) {
- echo "You have operator permissions. You can edit/ban everyone with a lower rank than yourself (designers, VIPs, streamers, users)";
- }
- if ($_SESSION['permissionset'] == 5) {
- echo "You have moderator permissions. You can edit/ban everyone with a lower rank than yourself (operators, designers, VIPs, streamers, users)";
- }
- if ($_SESSION['permissionset'] == 6) {
- echo "You are an administrator! You can edit/ban everyone with a lower rank than yourself (moderators, operators, designers, VIPs, streamers, users)";
- }
- if ($_SESSION['permissionset'] == 7) {
- echo "You are the owner, sir. You can do whatever you want except banning yourself, this must be done from the SQL database.";
- }
- echo "<br><br>";
- echo "<h3>Player list:</h3><br>";
- echo "<table><tr>";
- // Create connection
- $sql = "SELECT * FROM users ORDER BY permissionset DESC";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- $totalplayers = $result->num_rows;
- echo "<h4>$totalplayers total.</h4>";
- echo "<table class='table table-hover'>
- <thead>
- <tr>
- <th>User</th>
- <th>Coins</th>
- <th>Bets</th>
- <th>SteamID64</th>
- <th>Status</th>
- <th>Registered</th>
- <th>Last IP</th>
- <th>Banned</th>
- <th>Actions</th>
- </tr>
- </thead>
- ";
- while($row = $result->fetch_assoc()) {
- if ($row['ban'] == 1) {
- echo "<tr class='danger'>";
- }
- else {
- echo "<tr class='active'>";
- }
- echo "
- <td>
- <img src='" . $row['avatarsmall'] . "'>
- <b>" . $row["username"]. "</b>
- </td>
- <td>
- " . $row["coins"] . "
- </td>
- <td>
- " . $row['bets'] . "
- </td>
- <td>
- " . $row["steamid"]. "
- </td>";
- if ($row['permissionset'] == 7) {
- echo "<td><b>Owner <span class='glyphicon glyphicon-sunglasses'></span></b></td>";
- }
- if ($row['permissionset'] == 6) {
- echo "<td><b>Administrator</b></td>";
- }
- if ($row['permissionset'] == 5) {
- echo "<td><b>Moderator</b></td>";
- }
- if ($row['permissionset'] == 4) {
- echo "<td><b>Operator</b></td>";
- }
- if ($row['permissionset'] == 3) {
- echo "<td><b>Designer</b></td>";
- }
- if ($row['permissionset'] == 2) {
- echo "<td><b>VIP</b></td>";
- }
- if ($row['permissionset'] == 1) {
- echo "<td><b>Streamer</b></td>";
- }
- if ($row['permissionset'] == 0) {
- echo "<td>User</td>";
- }
- echo "<td>" . $row['registered'] . "</td>";
- echo "<td>" . $row['lastip'] . "</td>";
- if ($row['ban'] == 0) {
- echo "<td>No</td>";
- //Steamers, VIP or Designers are not allowed to ban or edit, at all.
- if ($_SESSION['permissionset'] < 4)
- {
- echo "<td>Not allowed</td>";
- }
- else {
- //Do not show the edit/ban buttons if the permissionset of selected user is higher than or equal to yours
- if ($row['permissionset'] >= $_SESSION['permissionset']) {
- echo "<td>Not allowed</td>";
- }
- //If it's not, show the buttons
- else {
- echo "<td>
- <form action='#editmodal' method='POST'>
- <input type='hidden' name='who' value='$row[steamid]'>
- <input type='hidden' name='whouser' value='$row[username]'>
- <input type='hidden' name='whoavatar' value='$row[avatarsmall]'>
- <input type='hidden' name='whopermission' value='$row[permissionset]'>
- <input type='hidden' name='whobets' value='$row[bets]'>
- <input type='hidden' name='whocoins' value='$row[coins]'>
- <button type='button' name='edit' class='btn btn-primary' data-toggle='modal' data-target='#editmodal'>Edit</button>
- </form>
- <form action='' method='POST'>
- <input type='hidden' name='who' value='$row[steamid]'>
- <input type='hidden' name='whouser' value='$row[username]'>
- <input type='hidden' name='whoavatar' value='$row[avatarsmall]'>
- <input type='hidden' name='whopermission' value='$row[permissionset]'>
- <input type='hidden' name='whobets' value='$row[bets]'>
- <input type='hidden' name='whocoins' value='$row[coins]'>
- <button type='submit' name='banuser' class='btn btn-danger'>Ban</button>
- </form>
- </td>
- ";
- }
- }
- }
- if ($row['ban'] == 1) {
- echo "<td>Yes</td>";
- //Steamers, VIP or Designers are not allowed to ban or edit, at all.
- if ($_SESSION['permissionset'] < 4)
- {
- echo "<td>Not allowed</td>";
- }
- else {
- //Do not show the edit/ban buttons if the permissionset of selected user is higher than or equal to yours
- if ($row['permissionset'] >= $_SESSION['permissionset']) {
- echo "<td>Not allowed</td>";
- }
- //Streamers, designers or VIP shouldn't be allowed to unban either
- if ($_SESSION['permissionset'] < 4)
- {
- echo "<td>Not allowed</td>";
- }
- else {
- echo "<td>
- <form action='#editmodal' method='POST'>
- <input type='hidden' name='who' value='$row[steamid]'>
- <input type='hidden' name='whouser' value='$row[username]'>
- <input type='hidden' name='whoavatar' value='$row[avatarsmall]'>
- <input type='hidden' name='whopermission' value='$row[permissionset]'>
- <input type='hidden' name='whobets' value='$row[bets]'>
- <input type='hidden' name='whocoins' value='$row[coins]'>
- <button type='button' name='edit' class='btn btn-primary' data-toggle='modal' data-target='#editmodal'>Edit</button>
- </form>
- <form action='' method='POST'>
- <input type='hidden' name='who' value='$row[steamid]'>
- <input type='hidden' name='whouser' value='$row[username]'>
- <input type='hidden' name='whoavatar' value='$row[avatarsmall]'>
- <input type='hidden' name='whopermission' value='$row[permissionset]'>
- <input type='hidden' name='whobets' value='$row[bets]'>
- <input type='hidden' name='whocoins' value='$row[coins]'>
- <button type='submit' name='unbanuser' class='btn btn-success'>Unban</button></td>
- </form>";
- }
- }
- }
- echo "</tr>";
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- echo "</tr></table>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement