mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-01-29 17:28:27 +00:00
Tabs, oh and IT FUCKING CHECKS IF YOU'RE AN ADMIN NOW REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
This commit is contained in:
parent
e28157de3c
commit
42e4de2e3b
41
account.php
41
account.php
|
@ -49,9 +49,16 @@
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<br>
|
||||
<h3>Logs</h3>
|
||||
<div id=logs" class="logs">
|
||||
|
||||
<div class="tabs">
|
||||
<button class="btn btn-neutral tablinks" onclick="openTab(event, 'logs')">Logs</button>
|
||||
<button class="btn btn-neutral tablinks" onclick="openTab(event, 'bans')">Bans</button>
|
||||
<button class="btn btn-neutral tablinks" onclick="openTab(event, 'users')">User settings</button>
|
||||
</div>
|
||||
|
||||
<div id="logs" class="logs tabcontent">
|
||||
<div class="log">
|
||||
<p>ID</p>
|
||||
<p>User IP</p>
|
||||
|
@ -77,9 +84,8 @@
|
|||
}
|
||||
?>
|
||||
</div>
|
||||
<br>
|
||||
<h3>Bans</h3>
|
||||
<div id="bans" class="bans">
|
||||
|
||||
<div id="bans" class="bans tabcontent">
|
||||
<div class="ban">
|
||||
<p>ID</p>
|
||||
<p>User IP</p>
|
||||
|
@ -111,9 +117,8 @@
|
|||
}
|
||||
?>
|
||||
</div>
|
||||
<br>
|
||||
<h3>User settings</h3>
|
||||
<div id="user-settings" class="user-settings">
|
||||
|
||||
<div id="users" class="user-settings tabcontent">
|
||||
|
||||
<div class="user">
|
||||
<p>ID</p>
|
||||
|
@ -196,12 +201,32 @@
|
|||
var toggleAdminSubmit = $("#toggleAdminSubmit").val();
|
||||
$("#sniffle").load("app/account/account.php", {
|
||||
id: toggleAdminSubmit,
|
||||
userId: <?php echo $_SESSION['id']; ?>,
|
||||
toggle_admin: toggleAdminSubmit
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function openTab(evt, tabName) {
|
||||
var i, tabcontent, tablinks;
|
||||
|
||||
tabcontent = document.getElementsByClassName("tabcontent");
|
||||
for (i = 0; i < tabcontent.length; i++) {
|
||||
tabcontent[i].style.display = "none";
|
||||
}
|
||||
|
||||
tablinks = document.getElementsByClassName("tablinks");
|
||||
for (i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(" active-tab", "");
|
||||
}
|
||||
|
||||
document.getElementById(tabName).style.display = "flex";
|
||||
evt.currentTarget.className += " active-tab";
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -429,49 +429,59 @@ if (isset($_POST['submit_signup'])) {
|
|||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($_POST['toggle_admin'])) {
|
||||
$is_admin = mysqli_query($conn, "SELECT * FROM users WHERE id = " . $_POST['id'] . " ORDER BY id DESC LIMIT 1");
|
||||
if ($user_info->is_admin($conn, $_POST['userId'])) {
|
||||
$is_admin = mysqli_query($conn, "SELECT * FROM users WHERE id = " . $_POST['id'] . " ORDER BY id DESC LIMIT 1");
|
||||
|
||||
while ($user_info = mysqli_fetch_assoc($is_admin)) {
|
||||
$admin_status = $user_info['admin'];
|
||||
$username = $user_info['username'];
|
||||
}
|
||||
|
||||
$sql = "UPDATE users SET admin = ? WHERE id = ?";
|
||||
|
||||
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||
// Bind variables to the prepared statement as parameters
|
||||
mysqli_stmt_bind_param($stmt, "ii", $param_admin_status, $param_user_id);
|
||||
|
||||
// Set parameters
|
||||
if ($admin_status) {
|
||||
$param_admin_status = 0;
|
||||
$admin_update_message = "removed from the admins list";
|
||||
} elseif (!$admin_status) {
|
||||
$param_admin_status = 1;
|
||||
$admin_update_message = "added to the admins list";
|
||||
while ($user_info = mysqli_fetch_assoc($is_admin)) {
|
||||
$admin_status = $user_info['admin'];
|
||||
$username = $user_info['username'];
|
||||
}
|
||||
$param_user_id = $_POST['id'];
|
||||
|
||||
// Attempt to execute the prepared statement
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Bap!', '<?php echo $username; ?> has been <?php echo $admin_update_message; ?>!', 'var(--green)', 'assets/icons/check.svg');
|
||||
flyoutClose();
|
||||
</script>
|
||||
<?php
|
||||
$sql = "UPDATE users SET admin = ? WHERE id = ?";
|
||||
|
||||
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||
// Bind variables to the prepared statement as parameters
|
||||
mysqli_stmt_bind_param($stmt, "ii", $param_admin_status, $param_user_id);
|
||||
|
||||
// Set parameters
|
||||
if ($admin_status) {
|
||||
$param_admin_status = 0;
|
||||
$admin_update_message = "removed from the admins list";
|
||||
} elseif (!$admin_status) {
|
||||
$param_admin_status = 1;
|
||||
$admin_update_message = "added to the admins list";
|
||||
}
|
||||
$param_user_id = $_POST['id'];
|
||||
|
||||
// Attempt to execute the prepared statement
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Bap!', '<?php echo $username; ?> has been <?php echo $admin_update_message; ?>!', 'var(--green)', 'assets/icons/check.svg');
|
||||
flyoutClose();
|
||||
</script>
|
||||
<?php
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','$username has been $admin_update_message')");
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
|
||||
flyoutClose();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
|
||||
flyoutClose();
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
|
||||
sniffleAdd('Bruh', 'You\'re not an admin, you cannot!!!!', 'var(--red)', 'assets/icons/cross.svg');
|
||||
flyoutClose();
|
||||
</script>
|
||||
<?php
|
||||
|
|
35
css/main.css
35
css/main.css
|
@ -637,13 +637,28 @@ nav .btn {
|
|||
font-family: "Secular One", sans-serif;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.tabs > button {
|
||||
margin-right: 0.5rem;
|
||||
width: 33.33%;
|
||||
}
|
||||
.tabs > button:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.active-tab {
|
||||
background-color: #8C977D !important;
|
||||
}
|
||||
|
||||
.logs {
|
||||
width: 100%;
|
||||
max-height: 21rem;
|
||||
min-height: auto;
|
||||
height: 21rem;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background-color: #151515;
|
||||
border-radius: calc(0.25rem - (0.5rem + 3px));
|
||||
|
@ -687,11 +702,10 @@ nav .btn {
|
|||
|
||||
.bans {
|
||||
width: 100%;
|
||||
max-height: 21rem;
|
||||
min-height: auto;
|
||||
height: 21rem;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background-color: #151515;
|
||||
border-radius: calc(0.25rem - (0.5rem + 3px));
|
||||
|
@ -730,7 +744,7 @@ nav .btn {
|
|||
}
|
||||
|
||||
.perm {
|
||||
border: 3px #B66467 solid;
|
||||
border-left: #B66467 0.2rem solid;
|
||||
}
|
||||
|
||||
.ban:first-of-type {
|
||||
|
@ -742,11 +756,10 @@ nav .btn {
|
|||
|
||||
.user-settings {
|
||||
width: 100%;
|
||||
max-height: 21rem;
|
||||
min-height: auto;
|
||||
height: 21rem;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
background-color: #151515;
|
||||
border-radius: calc(0.25rem - (0.5rem + 3px));
|
||||
|
@ -788,7 +801,7 @@ nav .btn {
|
|||
}
|
||||
|
||||
.is-admin {
|
||||
background-color: #8C977D !important;
|
||||
border-left: #8C977D 0.2rem solid;
|
||||
}
|
||||
|
||||
.user:first-of-type {
|
||||
|
|
|
@ -357,15 +357,30 @@
|
|||
@include defaultFont();
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex; flex-direction: row;
|
||||
|
||||
& > button {
|
||||
margin-right: 0.5rem;
|
||||
width: 33.33%;
|
||||
}
|
||||
& > button:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
.active-tab {
|
||||
background-color: $page-accent !important;
|
||||
}
|
||||
|
||||
.logs {
|
||||
width: 100%;
|
||||
max-height: 21rem; min-height: auto;
|
||||
height: 21rem;
|
||||
|
||||
padding: 0;
|
||||
|
||||
overflow-y: scroll;
|
||||
|
||||
display: flex; flex-direction: column;
|
||||
display: none; flex-direction: column;
|
||||
|
||||
background-color: $bg;
|
||||
border-radius: calc($rad - (0.5rem + 3px));
|
||||
|
@ -411,13 +426,13 @@
|
|||
|
||||
.bans {
|
||||
width: 100%;
|
||||
max-height: 21rem; min-height: auto;
|
||||
height: 21rem;
|
||||
|
||||
padding: 0;
|
||||
|
||||
overflow-y: scroll;
|
||||
|
||||
display: flex; flex-direction: column;
|
||||
display: none; flex-direction: column;
|
||||
|
||||
background-color: $bg;
|
||||
border-radius: calc($rad - (0.5rem + 3px));
|
||||
|
@ -459,7 +474,7 @@
|
|||
}
|
||||
}
|
||||
.perm {
|
||||
border: 3px $red solid;
|
||||
border-left: $red 0.2rem solid;
|
||||
}
|
||||
.ban:first-of-type {
|
||||
background-color: $bg;
|
||||
|
@ -469,13 +484,13 @@
|
|||
|
||||
.user-settings {
|
||||
width: 100%;
|
||||
max-height: 21rem; min-height: auto;
|
||||
height: 21rem;
|
||||
|
||||
padding: 0;
|
||||
|
||||
overflow-y: scroll;
|
||||
|
||||
display: flex; flex-direction: column;
|
||||
display: none; flex-direction: column;
|
||||
|
||||
background-color: $bg;
|
||||
border-radius: calc($rad - (0.5rem + 3px));
|
||||
|
@ -520,7 +535,7 @@
|
|||
}
|
||||
}
|
||||
.is-admin {
|
||||
background-color: $green !important;
|
||||
border-left: $page-accent 0.2rem solid;
|
||||
}
|
||||
.user:first-of-type {
|
||||
background-color: $bg;
|
||||
|
|
Loading…
Reference in a new issue