mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-06 10:23:12 +00:00
Cleaned up some stuffs in profile and upload
This commit is contained in:
parent
956758fa25
commit
7f2e01a7f1
3 changed files with 55 additions and 55 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -2,4 +2,6 @@
|
||||||
images/
|
images/
|
||||||
|
|
||||||
# CSS map, I don't think its needed for upload... I think?
|
# CSS map, I don't think its needed for upload... I think?
|
||||||
*.map
|
*.map
|
||||||
|
|
||||||
|
.idea/
|
28
profile.php
28
profile.php
|
@ -10,8 +10,8 @@
|
||||||
$diff = new Diff();
|
$diff = new Diff();
|
||||||
|
|
||||||
if (!isset($_GET['user']) || empty($_GET['user'])) {
|
if (!isset($_GET['user']) || empty($_GET['user'])) {
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
} elseif (isset($_GET['user'])) {
|
} else if (isset($_GET['user'])) {
|
||||||
$user = $user_info->get_user_info($conn, $_GET['user']);
|
$user = $user_info->get_user_info($conn, $_GET['user']);
|
||||||
|
|
||||||
$join_date = new DateTime($user['created_at']);
|
$join_date = new DateTime($user['created_at']);
|
||||||
|
@ -34,11 +34,7 @@
|
||||||
echo "<img src='images/pfp/".$user['pfp_path']."'>";
|
echo "<img src='images/pfp/".$user['pfp_path']."'>";
|
||||||
|
|
||||||
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
|
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
|
||||||
if (!empty($pfp_colour)) {
|
if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)";
|
||||||
$pfp_colour = $pfp_colour;
|
|
||||||
} else {
|
|
||||||
$pfp_colour = "var(--bg-3)";
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.profile-root {
|
.profile-root {
|
||||||
|
@ -58,7 +54,9 @@
|
||||||
<h2>
|
<h2>
|
||||||
<?php
|
<?php
|
||||||
echo $user['username'];
|
echo $user['username'];
|
||||||
if ($user_info->is_admin($conn, $user['id'])) echo "<span style='color: var(--accent); font-size: 16px; margin-left: 0.5rem;'>Admin</span>";
|
if ($user_info->is_admin($conn, $user['id'])) {
|
||||||
|
echo "<span style='color: var(--accent); font-size: 16px; margin-left: 0.5rem;'>Admin</span>";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="profile-info">
|
<div class="profile-info">
|
||||||
|
@ -69,7 +67,7 @@
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
echo "<img src='assets/no_image.png'>
|
echo "<img src='assets/no_image.png'>
|
||||||
<h2>Failed to load user info</h2>";
|
<h2>Failed to load user info</h2>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,20 +92,20 @@
|
||||||
while ($image = mysqli_fetch_array($query)) {
|
while ($image = mysqli_fetch_array($query)) {
|
||||||
// Getting thumbnail
|
// Getting thumbnail
|
||||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||||
$image_path = "images/thumbnails/".$image['imagename'];
|
$image_path = "images/thumbnails/" . $image['imagename'];
|
||||||
} else {
|
} else {
|
||||||
$image_path = "images/".$image['imagename'];
|
$image_path = "images/" . $image['imagename'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for NSFW tag
|
// Check for NSFW tag
|
||||||
if (str_contains($image['tags'], "nsfw")) {
|
if (str_contains($image['tags'], "nsfw")) {
|
||||||
echo "<div class='gallery-item'>
|
echo "<div class='gallery-item'>
|
||||||
<a href='image.php?id=".$image['id']."' class='nsfw-warning'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
<a href='image.php?id=" . $image['id'] . "' class='nsfw-warning'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
||||||
<a href='image.php?id=".$image['id']."'><img class='gallery-image nsfw-blur' loading='lazy' src='".$image_path."' id='".$image['id']."'></a>
|
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image nsfw-blur' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||||
</div>";
|
</div>";
|
||||||
} else {
|
} else {
|
||||||
echo "<div class='gallery-item'>
|
echo "<div class='gallery-item'>
|
||||||
<a href='image.php?id=".$image['id']."'><img class='gallery-image' loading='lazy' src='".$image_path."' id='".$image['id']."'></a>
|
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||||
</div>";
|
</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
78
upload.php
78
upload.php
|
@ -18,7 +18,7 @@
|
||||||
if (!$user_info->is_loggedin()) {
|
if (!$user_info->is_loggedin()) {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--alert)', 'assets/icons/cross.svg');
|
sniffleAdd('Who are you!', 'You must be logged in to upload things, sowwy!', 'var(--alert)', 'assets/icons/cross.svg');
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -50,49 +50,49 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$("#uploadSubmit").submit(function(event) {
|
$('#uploadSubmit').submit(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// Check if image avalible
|
// Check if image available
|
||||||
var file = $("#image").val();
|
var file = $("#image").val();
|
||||||
if (file != "") {
|
if (file == "") {
|
||||||
// Make form
|
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
|
||||||
var formData = new FormData();
|
} else {
|
||||||
|
// Make form
|
||||||
|
var formData = new FormData();
|
||||||
|
|
||||||
// Get image
|
// Get image
|
||||||
var image_data = $("#image").prop("files")[0];
|
var image_data = $("#image").prop("files")[0];
|
||||||
formData.append("image", image_data);
|
formData.append("image", image_data);
|
||||||
// Get ALT
|
// Get ALT
|
||||||
var alt = $("#alt").val();
|
var alt = $("#alt").val();
|
||||||
formData.append("alt", alt);
|
formData.append("alt", alt);
|
||||||
// Get TAGS
|
// Get TAGS
|
||||||
var tags = $("#tags").val();
|
var tags = $("#tags").val();
|
||||||
formData.append("tags", tags);
|
formData.append("tags", tags);
|
||||||
// Submit data
|
// Submit data
|
||||||
var submit = $("#submit").val();
|
var submit = $("#submit").val();
|
||||||
formData.append("submit", submit);
|
formData.append("submit", submit);
|
||||||
|
|
||||||
// Upload the information
|
// Upload the information
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'app/image/upload_image.php',
|
url: 'app/image/upload_image.php',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
$("#newSniff").html(response);
|
$("#newSniff").html(response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Empty values
|
// Empty values
|
||||||
imagePreview.src = "";
|
imagePreview.src = "";
|
||||||
$("#image").val("");
|
$("#image").val("");
|
||||||
$("#alt").val("");
|
$("#alt").val("");
|
||||||
$("#tags").val("");
|
$("#tags").val("");
|
||||||
$("#submit").val("");
|
$("#submit").val("");
|
||||||
} else {
|
}
|
||||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue