Automated loading of more logs

Fixed other random bugs
This commit is contained in:
Michał Gdula 2022-11-08 15:37:19 +00:00
parent 517d0b7071
commit 2d7d359cde
11 changed files with 151 additions and 95 deletions

View file

@ -33,11 +33,7 @@
<div class="defaultDecoration defaultSpacing defaultFonts"> <div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Profile</h2> <h2>Profile</h2>
<div class="pfp-upload"> <div class="pfp-upload">
<form id="pfpForm" method="POST" enctype="multipart/form-data"> <h3>Profile Picture</h3>
<h3>Profile Picture</h3>
<input id="image" class="btn btn-neutral" type="file" placeholder="select image UwU">
<button id="pfpSubmit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
</form>
<?php <?php
if (is_file("usr/images/pfp/".$profile_info['pfp_path'])) { if (is_file("usr/images/pfp/".$profile_info['pfp_path'])) {
echo "<img alt='profile picture' src='usr/images/pfp/".$profile_info['pfp_path']."'>"; echo "<img alt='profile picture' src='usr/images/pfp/".$profile_info['pfp_path']."'>";
@ -45,6 +41,10 @@
echo "<img alt='profile picture' src='assets/no_image.png'>"; echo "<img alt='profile picture' src='assets/no_image.png'>";
} }
?> ?>
<form id="pfpForm" method="POST" enctype="multipart/form-data">
<input id="image" class="btn btn-neutral" type="file" placeholder="select image UwU">
<button id="pfpSubmit" class="btn btn-good btn-icon" type="submit"><img class="svg" src="assets/icons/upload.svg"></button>
</form>
<script> <script>
$("#pfpForm").submit(function(event) { $("#pfpForm").submit(function(event) {
event.preventDefault(); event.preventDefault();
@ -162,26 +162,33 @@
<h2>Website</h2> <h2>Website</h2>
<h3>Invite Codes</h3> <h3>Invite Codes</h3>
<?php <div style="display: flex; flex-direction: column; gap: 0.5rem;" id="tokenList">
$token_request = mysqli_query($conn, "SELECT * FROM tokens WHERE used = 0"); <?php
if (mysqli_num_rows($token_request) > 0) { $token_request = mysqli_query($conn, "SELECT * FROM tokens WHERE used = 0");
while ($token = mysqli_fetch_array($token_request)) { if (mysqli_num_rows($token_request) > 0) {
?> while ($token = mysqli_fetch_array($token_request)) {
<div style="display: flex; flex-direction: row; gap: 0.5rem;"> ?>
<button onclick='copyCode(this)' class='btn btn-neutral btn-code'><?php echo $token['code']; ?></button> <div style="display: flex; flex-direction: row; gap: 0.5rem;">
<button onclick='regenerateCode("<?php echo $token["code"]; ?>", this)' class='btn btn-good btn-code-reg'><img src="assets/icons/arrow-clockwise.svg"></button> <button onclick='copyCode(this)' class='btn btn-neutral btn-code'><?php echo $token['code']; ?></button>
<button onclick='deleteCode(<?php echo $token["id"]; ?>)' class='btn btn-bad btn-code-reg'><img src="assets/icons/cross.svg"></button> <button onclick='regenerateCode("<?php echo $token["code"]; ?>", this)' class='btn btn-good btn-icon'><img src="assets/icons/arrow-clockwise.svg"></button>
</div> <button onclick='deleteCode(<?php echo $token["id"]; ?>)' class='btn btn-bad btn-icon'><img src="assets/icons/cross.svg"></button>
<?php </div>
} <?php
} else { }
echo "<div class='info-text defaultFonts' style='text-align: center !important; margin-left: 0 !important;'> } else {
<p>No invite codes/tokens :c</p> echo "<div class='info-text defaultFonts' style='text-align: center !important; margin-left: 0 !important;'>
</div>"; <p>No invite codes/tokens :c</p>
} </div>";
?> }
?>
</div>
<button onclick='generateCode()' class='btn btn-good'>Generate code</button> <button onclick='generateCode()' class='btn btn-good'>Generate code</button>
<script> <script>
function refreshList() {
$("#tokenList").load("app/account/token.php", {
refresh: 'true'
});
}
function copyCode(thisButton) { function copyCode(thisButton) {
var text = thisButton.innerHTML; var text = thisButton.innerHTML;
navigator.clipboard.writeText(text); navigator.clipboard.writeText(text);
@ -196,10 +203,13 @@
success: function(response) { success: function(response) {
if (response == true) { if (response == true) {
sniffleAdd("Woop!", "Invite code has been regenerated!", "var(--green)", "assets/icons/check.svg"); sniffleAdd("Woop!", "Invite code has been regenerated!", "var(--green)", "assets/icons/check.svg");
//thisButton.parentNode.remove(); refreshList();
} else { } else {
sniffleAdd("Oops!", "Something went wrong!", "var(--red)", "assets/icons/cross.svg"); sniffleAdd("Oops!", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
},
error: function() {
sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
}); });
} }
@ -212,9 +222,13 @@
success: function(response) { success: function(response) {
if (response == true) { if (response == true) {
sniffleAdd("Woop!", "Invite code has been generated!", "var(--green)", "assets/icons/check.svg"); sniffleAdd("Woop!", "Invite code has been generated!", "var(--green)", "assets/icons/check.svg");
refreshList();
} else { } else {
sniffleAdd("Oops!", "Something went wrong!", "var(--red)", "assets/icons/cross.svg"); sniffleAdd("Oops!", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
},
error: function() {
sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
}); });
} }
@ -227,10 +241,32 @@
success: function(response) { success: function(response) {
if (response == true) { if (response == true) {
sniffleAdd("Woop!", "Invite code has been deleted!", "var(--green)", "assets/icons/check.svg"); sniffleAdd("Woop!", "Invite code has been deleted!", "var(--green)", "assets/icons/check.svg");
//thisButton.parentNode.remove(); refreshList();
} else { } else {
sniffleAdd("Oops!", "Something went wrong!", "var(--red)", "assets/icons/cross.svg"); sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
},
error: function() {
sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
}
});
}
function gwa() {
$.ajax ({
url: "app/account/token.php",
type: "POST",
data: { gwagwa: true },
success: function(response) {
if (response == true) {
sniffleAdd("Woop!", "Invite code has been deleted!", "var(--green)", "assets/icons/check.svg");
refreshList();
} else {
sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
}
},
error: function() {
sniffleAdd("AAAAAAAAAAAAAAAAA", "Something went wrong!", "var(--red)", "assets/icons/cross.svg");
} }
}); });
} }
@ -266,7 +302,6 @@
} }
?> ?>
<div> <div>
<button class="btn btn-neutral" onclick="loadMore()">Load More</button>
<script> <script>
function loadMore() { function loadMore() {
$.ajax ({ $.ajax ({
@ -279,10 +314,19 @@
} }
}); });
} }
if ($("#logs").children().length > 100) {
var trueHeight = $("#logs").children().length * document.getElementById('logs').children.item(1).clientHeight;
$('#logs').scroll (function() {
if ($(this).scrollTop() + $(this).innerHeight() >= trueHeight - 100) {
loadMore();
}
});
}
</script> </script>
</div> </div>
</div> </div>
<div id="bans" class="bans tabcontent"> <div id="bans" class="bans tabcontent">
<div class="ban"> <div class="ban">
<p>ID</p> <p>User IP</p> <p>Reason</p> <p>Lenght</p> <p>Time</p> <p>ID</p> <p>User IP</p> <p>Reason</p> <p>Lenght</p> <p>Time</p>

View file

@ -698,7 +698,7 @@ if (isset($_POST['account_delete_submit'])) {
if (isset($_POST['pfp_submit'])) { if (isset($_POST['pfp_submit'])) {
if (isset($_SESSION['id'])) { if (isset($_SESSION['id'])) {
// Root paths // Root paths
$dir = "../../images/pfp/"; $dir = "../../usr/images/pfp/";
// File name updating // File name updating
$file_type = pathinfo($dir.$_FILES['image']['name'],PATHINFO_EXTENSION); $file_type = pathinfo($dir.$_FILES['image']['name'],PATHINFO_EXTENSION);

View file

@ -59,3 +59,24 @@ if (isset($_POST['delete'])) {
} }
} }
} }
if (isset($_POST['refresh'])) {
if ($user_info->is_admin($conn, $_SESSION['id'])) {
$request = mysqli_query($conn, "SELECT * FROM tokens WHERE used = 0");
if (mysqli_num_rows($request) > 0) {
while ($token = mysqli_fetch_array($request)) {
?>
<div style="display: flex; flex-direction: row; gap: 0.5rem;">
<button onclick='copyCode(this)' class='btn btn-neutral btn-code'><?php echo $token['code']; ?></button>
<button onclick='regenerateCode("<?php echo $token["code"]; ?>", this)' class='btn btn-good btn-icon'><img src="assets/icons/arrow-clockwise.svg"></button>
<button onclick='deleteCode(<?php echo $token["id"]; ?>)' class='btn btn-bad btn-icon'><img src="assets/icons/cross.svg"></button>
</div>
<?php
}
} else {
echo "<div class='info-text defaultFonts' style='text-align: center !important; margin-left: 0 !important;'>
<p>No invite codes/tokens :c</p>
</div>";
}
}
}

View file

@ -1,5 +1,5 @@
{ {
"license": "MIT", "license": "MIT",
"version": "22.11.06", "version": "22.11.08",
"branch": "main" "branch": "main"
} }

View file

@ -39,6 +39,11 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
'link'=>'https://github.com/Fluffy-Bean/image-gallery', 'link'=>'https://github.com/Fluffy-Bean/image-gallery',
'fix'=>'manual' 'fix'=>'manual'
); );
} else {
$results[] = array(
'type'=>'success',
'message'=>'You are running the latest version of the app v'.$app_repo['version']
);
} }
if (PHP_VERSION_ID < 80000) { if (PHP_VERSION_ID < 80000) {

View file

@ -54,8 +54,10 @@ if (isset($_POST['check'])) {
foreach ($results as $result) { foreach ($results as $result) {
if ($result['type'] == 'critical') { if ($result['type'] == 'critical') {
echo "<p class='alert alert-bad'><span class='badge badge-critical'>Critical</span> "; echo "<p class='alert alert-bad'><span class='badge badge-critical'>Critical</span> ";
} else { } elseif ($result['type'] == 'warning') {
echo "<p class='alert alert-warning'><span class='badge badge-warning'>Warning</span> "; echo "<p class='alert alert-warning'><span class='badge badge-warning'>Warning</span> ";
} elseif ($result['type'] == 'success') {
echo "<p class='alert alert-good'><span class='badge badge-primary'>Success</span> ";
} }
if ($result['fix'] == 'auto') { if ($result['fix'] == 'auto') {

View file

@ -24,14 +24,11 @@
<footer> <footer>
<p>Copyright <?php echo $user_settings['user_name']; ?></p> <p>Copyright <?php echo $user_settings['user_name']; ?></p>
<hr>
<a class='link' href="https://github.com/Fluffy-Bean/image-gallery">Made by Fluffy</a> <a class='link' href="https://github.com/Fluffy-Bean/image-gallery">Made by Fluffy</a>
<hr>
<p>V<?php echo $web_info['version']; ?></p> <p>V<?php echo $web_info['version']; ?></p>
<?php <?php
if ($exec_time != 0) { if ($exec_time != 0) {
echo "<hr> echo "<p>Generated in ".$exec_time."ms ".$sql_time."</p>";
<p>Generated in ".$exec_time."ms ".$sql_time."</p>";
} }
?> ?>
</footer> </footer>

View file

@ -729,37 +729,27 @@ nav .btn {
|------------------------------------------------------------- |-------------------------------------------------------------
*/ */
.pfp-upload { .pfp-upload {
display: flex;
flex-direction: column;
}
.pfp-upload form {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 0.5rem;
} }
.pfp-upload form > * { .pfp-upload form > * {
margin: 0 0 0.5rem 0; margin: 0;
}
.pfp-upload form > *:last-child {
margin: 0 0 0 0;
} }
.pfp-upload > img { .pfp-upload > img {
margin-left: 0.5rem; margin: 0 auto 1rem;
width: 8rem; width: 12rem;
height: 8rem; height: 12rem;
-o-object-fit: cover; -o-object-fit: cover;
object-fit: cover; object-fit: cover;
float: right;
border-radius: 3px; border-radius: 3px;
background-color: #121212; background-color: #121212;
} }
@media (max-width: 621px) {
.pfp-upload {
display: flex;
flex-direction: column-reverse;
}
.pfp-upload > img {
margin: 0 auto 1rem;
width: 12rem;
height: 12rem;
}
}
.tabs { .tabs {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -946,7 +936,7 @@ nav .btn {
position: relative; position: relative;
} }
.btn-code::before { .btn-code::before {
content: "Hover to show code"; content: "Hover to reveal";
color: #E8E3E3; color: #E8E3E3;
position: absolute; position: absolute;
top: 50%; top: 50%;
@ -960,11 +950,11 @@ nav .btn {
content: ""; content: "";
} }
.btn-code-reg { .btn-icon {
width: auto !important; width: auto !important;
display: inline-block !important; display: inline-block !important;
} }
.btn-code-reg img { .btn-icon img {
margin: auto 2px; margin: auto 2px;
width: 1.25rem; width: 1.25rem;
height: 1.25rem; height: 1.25rem;
@ -999,15 +989,18 @@ footer {
text-transform: uppercase; text-transform: uppercase;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 0.5rem;
} }
footer p { footer p {
margin: 0.2rem; margin: 0;
padding: 0; padding: 0;
text-decoration: none; text-decoration: none;
font-family: "Secular One", sans-serif; font-family: "Secular One", sans-serif;
} }
footer a { footer a {
margin: 0.2rem; margin: 0;
padding: 0; padding: 0;
text-decoration: none; text-decoration: none;
font-family: "Secular One", sans-serif; font-family: "Secular One", sans-serif;
@ -1068,7 +1061,8 @@ body * {
text-decoration: none; text-decoration: none;
border: none; border: none;
border-radius: 3px; border-radius: 3px;
transition: outline 0.1s cubic-bezier(0.19, 1, 0.22, 1); outline: #E8E3E3 0 solid;
transition: outline 0.1s;
/* /*
&::after { &::after {
content: ""; content: "";
@ -1108,7 +1102,7 @@ body * {
*/ */
} }
.btn:where(input[type=file])::-webkit-file-upload-button { .btn:where(input[type=file])::-webkit-file-upload-button {
margin: -0.25rem 0.5rem -0.25rem -0.25rem; margin: -0.5rem 0.5rem -0.5rem -0.5rem;
padding: 0.5rem; padding: 0.5rem;
display: inline-block; display: inline-block;
font-size: 16px; font-size: 16px;
@ -1119,7 +1113,7 @@ body * {
border-radius: 3px; border-radius: 3px;
} }
.btn:where(input[type=file])::file-selector-button { .btn:where(input[type=file])::file-selector-button {
margin: -0.25rem 0.5rem -0.25rem -0.25rem; margin: -0.5rem 0.5rem -0.5rem -0.5rem;
padding: 0.5rem; padding: 0.5rem;
display: inline-block; display: inline-block;
font-size: 16px; font-size: 16px;
@ -1259,7 +1253,7 @@ a.btn {
*/ */
form { form {
width: 100%; width: 100%;
box-sizing: content-box; box-sizing: border-box;
} }
form > * { form > * {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;

View file

@ -85,7 +85,9 @@ body {
border-radius: 3px; border-radius: 3px;
} }
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1); outline: $fg 0 solid;
transition: outline 0.1s;
/* /*
&::after { &::after {
@ -112,7 +114,7 @@ body {
*/ */
&:hover { &:hover {
outline: $white 0.2rem solid; outline: $fg $border-thickness solid;
color: $fg; color: $fg;
cursor: pointer; cursor: pointer;
@ -129,7 +131,7 @@ body {
} }
&:where(input[type="file"])::file-selector-button { &:where(input[type="file"])::file-selector-button {
margin: -0.25rem 0.5rem -0.25rem -0.25rem; margin: -0.5rem 0.5rem -0.5rem -0.5rem;
padding: 0.5rem; padding: 0.5rem;
display: inline-block; display: inline-block;
@ -301,7 +303,7 @@ a.btn {
*/ */
form { form {
width: 100%; width: 100%;
box-sizing: content-box; box-sizing: border-box;
& > * { & > * {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;

View file

@ -717,25 +717,26 @@
*/ */
.pfp-upload { .pfp-upload {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
form > * { form {
margin: 0 0 0.5rem 0; display: flex;
} flex-direction: row;
form > *:last-child { gap: 0.5rem;
margin: 0 0 0 0;
> * {
margin: 0;
}
} }
& > img { & > img {
margin-left: 0.5rem; margin: 0 auto 1rem;
width: 8rem; width: 12rem;
height: 8rem; height: 12rem;
object-fit: cover; object-fit: cover;
float: right;
@if calc($rad - 0.5rem) > 0 { @if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem); border-radius: calc($rad - 0.5rem);
} @else { } @else {
@ -745,19 +746,6 @@
} }
} }
@media (max-width: 621px) {
.pfp-upload {
display: flex;
flex-direction: column-reverse;
& > img {
margin: 0 auto 1rem;
width: 12rem;
height: 12rem;
}
}
}
.tabs { .tabs {
display: flex; flex-direction: row; display: flex; flex-direction: row;
@ -976,7 +964,7 @@
position: relative; position: relative;
&::before { &::before {
content: "Hover to show code"; content: "Hover to reveal";
color: $fg; color: $fg;
position: absolute; position: absolute;
@ -994,7 +982,7 @@
} }
} }
.btn-code-reg { .btn-icon {
width: auto !important; width: auto !important;
display: inline-block !important; display: inline-block !important;

View file

@ -13,9 +13,12 @@ footer {
text-transform: uppercase; text-transform: uppercase;
display: flex; flex-direction: row; display: flex; flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 0.5rem;
p { p {
margin: 0.2rem; margin: 0;
padding: 0; padding: 0;
text-decoration: none; text-decoration: none;
@ -24,7 +27,7 @@ footer {
} }
a { a {
margin: 0.2rem; margin: 0;
padding: 0; padding: 0;
text-decoration: none; text-decoration: none;