Rewriting classes for de-oopsie-ing

This commit is contained in:
Michał Gdula 2022-10-06 12:06:14 +00:00
parent 7f1782d7c6
commit 646b41e90a
7 changed files with 42 additions and 20 deletions

View file

@ -30,7 +30,7 @@
unset($_SESSION['err']);
}
if ($user_info->is_loggedin()) {
if ($user_info->is_loggedin($conn)) {
?>
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Profile</h2>

View file

@ -345,7 +345,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Argh', 'Your invite code/token did not check out, woopsie!', 'var(--warning)', 'assets/icons/cross.svg');
sniffleAdd('Argh', 'Your invite code did not check out, woopsie!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -353,7 +353,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Woops', 'The server or website died inside and could not process your information, sowwy!', 'var(--warning)', 'assets/icons/cross.svg');
sniffleAdd('Woops', 'The server or website died inside and could not process your request, sowwy!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -390,7 +390,7 @@ if (isset($_POST['submit_signup'])) {
$token_array = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
$new_token = substr(str_shuffle($token_array), 0, 15);
mysqli_query($conn, "INSERT INTO tokens (code, used) VALUES('$new_toke', False)");
mysqli_query($conn, "INSERT INTO tokens (code, used) VALUES('$new_toke', 0)");
}
// Yupeee! Account was made
@ -400,7 +400,7 @@ if (isset($_POST['submit_signup'])) {
loginShow();
</script>
<?php
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New account (".$username.") has been made')");
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New account ($username) has been made')");
} else {
?>
<script>
@ -501,7 +501,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Meep', 'Enter a new password!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
@ -509,7 +508,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Not long enough...', 'Password, must be 6 or more characters in length uwu', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
@ -522,7 +520,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Meep', 'You must confirm the password!!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
@ -532,7 +529,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('AAAA', 'Passwords do not match!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
@ -547,7 +543,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Oopsie', 'An error occured while figuring out which user to change the password of... Are you an admin?', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
@ -582,7 +577,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Password updated', 'Password has been reset for user! But their session may still be active', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
}
@ -590,7 +584,6 @@ if (isset($_POST['password_reset_submit'])) {
?>
<script>
sniffleAdd('Bruh', 'Something happened on our end, sowwy', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}

View file

@ -1054,6 +1054,7 @@ body * {
padding: 0.5rem;
display: inline-block;
font-size: 16px;
font-family: "Secular One", sans-serif;
text-decoration: none;
background-color: #E8E3E3;
border: none;
@ -1064,11 +1065,17 @@ body * {
padding: 0.5rem;
display: inline-block;
font-size: 16px;
font-family: "Secular One", sans-serif;
text-decoration: none;
background-color: #E8E3E3;
border: none;
border-radius: 3px;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
outline: none;
}
a.btn {
text-align: center;

View file

@ -100,6 +100,7 @@ body {
display: inline-block;
font-size: 16px;
font-family: $font-body;
text-decoration: none;
@ -112,6 +113,12 @@ body {
border-radius: 3px;
}
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
outline: none;
}
}
a.btn {

View file

@ -26,12 +26,21 @@
unset($_SESSION['del']);
}
if (isset($_SESSION['welc'])) {
?>
<script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'assets/icons/hand-waving.svg');
</script>
<?php
unset($_SESSION['welc']);
$user = $user_info->get_user_info($conn, $_SESSION['id']);
if (isset($user['pfp_path'])) {
?>
<script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'images/pfp/<?php echo $user["pfp_path"]; ?>');
</script>
<?php
} else {
?>
<script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'assets/icons/hand-waving.svg');
</script>
<?php
}
if ($user_info->is_admin($conn, $_SESSION['id'])) {
$check_sanity = $sanity->get_results();
@ -43,6 +52,8 @@
<?php
}
}
unset($_SESSION['welc']);
}
if (isset($_SESSION['err'])) {
?>

View file

@ -6,7 +6,7 @@
$user_info = new Account();
// Check if the user is logged in, otherwise redirect to login page
if ($user_info->is_loggedin() != true) {
if ($user_info->is_loggedin($conn) == false) {
header("location: account.php");
}
?>
@ -26,6 +26,8 @@
<p>After reset, you will be kicked out to login again</p>
<br>
<form id="passwordForm" method="POST" enctype="multipart/form-data">
<input id="currentPassword" class="btn btn-neutral" placeholder="Current password!!!!" type='password' disabled>
<br>
<input id="newPassword" class="btn btn-neutral" type="password" name="new_password" placeholder="New Password">
<input id="confirmPassword" class="btn btn-neutral" type="password" name="confirm_password" placeholder="Confirm Password">
<br>
@ -38,11 +40,13 @@
<script>
$("#passwordForm").submit(function(event) {
event.preventDefault();
var current_password = $("#currentPassword").val();
var new_password = $("#newPassword").val();
var confirm_password = $("#confirmPassword").val();
var submit = $("#passwordSubmit").val();
$("#newSniff").load("app/account/account.php", {
current_password: current_password,
new_password: new_password,
confirm_password: confirm_password,
password_reset_submit: submit

View file

@ -5,7 +5,7 @@
$user_info = new Account();
// Check if user is logged in
if (!$user_info->is_loggedin()) {
if (!$user_info->is_loggedin($conn)) {
$_SESSION['err'] = "You must be logged in to upload images!!!!!!!!";
header("location: account.php");
}