php-gallery/index.php

82 lines
2.3 KiB
PHP
Raw Normal View History

2022-09-24 16:47:34 +00:00
<?php require_once __DIR__."/app/required.php"; ?>
2022-09-21 13:02:38 +00:00
2022-07-20 23:06:21 +00:00
<!DOCTYPE html>
<html>
2022-08-11 18:28:52 +00:00
2022-09-06 16:14:43 +00:00
<head>
2022-09-21 13:37:45 +00:00
<?php require_once __DIR__."/assets/ui/header.php"; ?>
2022-07-20 23:06:21 +00:00
</head>
2022-09-06 16:14:43 +00:00
2022-07-20 23:06:21 +00:00
<body>
2022-09-21 13:02:38 +00:00
<?php
2022-09-21 13:37:45 +00:00
require_once __DIR__."/assets/ui/nav.php";
2022-09-21 13:02:38 +00:00
if ($_GET['del']) {
?>
<script>
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "assets/icons/trash.svg");
</script>
<?php
}
?>
2022-08-11 18:28:52 +00:00
2022-09-24 10:18:00 +00:00
<div class="info-text defaultFonts">
2022-08-11 18:28:52 +00:00
<?php
// Set time for message
$time = date("H");
$timezone = date("e");
if ($time < "12") {
$time_welc = "Good morning";
} else if ($time >= "12" && $time < "17") {
$time_welc = "Good afternoon";
} else if ($time >= "17" && $time < "19") {
$time_welc = "Good evening";
} else if ($time >= "19") {
$time_welc = "Good night";
}
// Welcome depending on if user is logged in or not
if (isset($_SESSION["username"])) {
echo "<h1>".$time_welc." ".$_SESSION['username']."!</h1>";
} else {
echo "<h1>".$time_welc."!</h1>";
}
// Random welcome message
2022-09-20 15:47:23 +00:00
$welcome_message = $user_settings['welcome_msg'];
2022-08-11 18:28:52 +00:00
echo "<p>".$welcome_message[array_rand($welcome_message, 1)]."</p>";
?>
</div>
2022-09-24 10:18:00 +00:00
<div class="gallery-root defaultDecoration">
2022-08-11 18:28:52 +00:00
<?php
2022-09-14 14:08:50 +00:00
// Reading images from table
$image_request = mysqli_query($conn, "SELECT * FROM images ORDER BY id DESC");
2022-08-11 18:28:52 +00:00
2022-09-14 14:08:50 +00:00
while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
2022-08-11 18:28:52 +00:00
2022-09-14 14:08:50 +00:00
// Check for NSFW tag
if (str_contains($image['tags'], "nsfw")) {
2022-09-23 17:26:15 +00:00
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']."'><img class='gallery-image nsfw-blur' loading='lazy' src='".$image_path."' id='".$image['id']."'></a>
</div>";
2022-09-14 14:08:50 +00:00
} else {
2022-09-23 17:26:15 +00:00
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>
</div>";
2022-09-14 14:08:50 +00:00
}
}
2022-08-11 18:28:52 +00:00
?>
</div>
2022-09-21 13:37:45 +00:00
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
2022-07-20 23:06:21 +00:00
</body>
</html>