php-gallery/index.php

117 lines
3.9 KiB
PHP
Raw Normal View History

2022-08-03 16:46:50 +00:00
<?php include "ui/required.php"; ?>
2022-07-20 23:06:21 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2022-08-03 16:46:50 +00:00
<title>Lynx Gallery</title>
<!-- Google Fonts -->
2022-07-21 14:53:04 +00:00
<link rel="stylesheet" href="css/master.css">
2022-07-22 00:21:48 +00:00
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600&amp;display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@500&amp;display=swap">
2022-08-03 16:46:50 +00:00
<!-- JQuery -->
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
2022-08-06 09:52:40 +00:00
<!-- Sniffle script! -->
<script src="Sniffle/sniffle.js"></script>
<link rel='stylesheet' href='Sniffle/sniffle.css'>
<!-- Flyout script! -->
<script src="Flyout/flyout.js"></script>
<link rel='stylesheet' href='Flyout/flyout.css'>
2022-07-20 23:06:21 +00:00
</head>
<body>
2022-08-02 13:13:35 +00:00
<?php
2022-08-03 16:46:50 +00:00
include "ui/nav.php";
2022-08-02 13:13:35 +00:00
?>
2022-07-25 15:13:26 +00:00
2022-08-06 09:52:40 +00:00
<script>
2022-08-06 21:14:05 +00:00
sniffleAdd("Warning", "The website is currently being worked on, people who have accounts, I ask you kindly to not post anything. Thank you.", "var(--red)", "<?php echo $root_dir ?>assets/icons/warning.svg");
2022-08-06 09:52:40 +00:00
if (params.del == "true") {
2022-08-06 21:14:05 +00:00
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "<?php echo $root_dir ?>assets/icons/trash.svg");
2022-08-01 13:09:53 +00:00
}
2022-08-06 09:52:40 +00:00
if (params.login == "success") {
2022-08-06 21:14:05 +00:00
sniffleAdd("Logged in", "O hi <?php echo $_SESSION['username']; ?>", "var(--green)", "<?php echo $root_dir ?>assets/icons/hand-waving.svg");
2022-08-01 13:09:53 +00:00
}
2022-08-06 09:52:40 +00:00
</script>
2022-07-31 11:50:52 +00:00
2022-08-01 13:09:53 +00:00
<?php
2022-07-31 11:50:52 +00:00
// Show search
if ($_GET["srch"] == "show") {
$header = "Search for a tags!";
$content = "Here you can search for funnies! Like raccoons!!!!!!!!!";
$action = "<form class='flex-down between' method='POST' enctype='multipart/form-data'>
<input class='btn alert-default space-bottom' type='text' name='search' placeholder='👀'>
<button class='btn alert-high' type='submit' name='search_confirm' value=''><img class='svg' src='assets/icons/binoculars.svg'>Search</button>
</form>";
flyout($header, $content, $action);
}
/*
Search Confirm
*/
if (isset($_POST['search_confirm'])) {
// Unset all the variables, needed by flyout
unset($header, $content, $action);
// Clean input
2022-08-01 13:09:53 +00:00
$tags_string = tag_clean(trim($_POST['search']));
2022-07-31 11:50:52 +00:00
2022-08-03 16:46:50 +00:00
header("Location:index.php?q=".$tags_string);
2022-07-31 11:50:52 +00:00
}
if (isset($_GET["q"])) {
2022-08-01 13:09:53 +00:00
echo "<p class='alert alert-default space-bottom'>Search results for: ".$_GET['q']."</p>";
2022-07-31 11:50:52 +00:00
}
2022-07-21 18:42:03 +00:00
?>
<div class="info-text center">
2022-07-25 15:13:26 +00:00
<?php
2022-07-25 17:28:55 +00:00
// Welcome depending on if user is logged in or not
2022-07-25 15:13:26 +00:00
if (isset($_SESSION["username"])) {
echo "<h1>Welcome ".$_SESSION['username']."!</h1>";
} else {
echo "<h1>Welcome!</h1>";
}
2022-07-25 17:28:55 +00:00
// Random welcome message
2022-07-26 17:16:17 +00:00
$welcome_message = array("*internal screaming*", "Sussy Wussy", "What is this world?", "Don't forget to drink water!", "Bruh", "This is so poorly programmed", "Sorry", "Fluffy made this!", "maybe", "I'm gay");
2022-07-25 17:28:55 +00:00
echo "<p>".$welcome_message[array_rand($welcome_message, 1)]."</p>";
2022-07-25 15:13:26 +00:00
?>
2022-07-21 18:42:03 +00:00
</div>
2022-07-20 23:06:21 +00:00
2022-07-21 14:53:04 +00:00
<div class="gallery-root flex-left">
2022-07-20 23:06:21 +00:00
<?php
// Reading images from table
2022-08-01 18:20:51 +00:00
$image_request = mysqli_query($conn, "SELECT * FROM swag_table ORDER BY id DESC");
2022-07-24 09:43:54 +00:00
while ($image = mysqli_fetch_array($image_request)) {
2022-07-31 11:50:52 +00:00
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
2022-07-24 12:20:12 +00:00
2022-07-31 11:50:52 +00:00
// Image loading
echo "<div class='gallery-item'>";
2022-08-03 16:46:50 +00:00
echo "<a href='image.php?id=".$image['id']."'><img class='gallery-image' loading='lazy' src='".$image_path."' id='".$image['id']."'></a>";
2022-07-31 11:50:52 +00:00
echo "</div>";
2022-07-20 23:06:21 +00:00
}
?>
</div>
2022-07-26 12:34:48 +00:00
<?php
2022-08-03 16:46:50 +00:00
include "ui/top.html";
include "ui/footer.php";
2022-07-26 12:34:48 +00:00
?>
2022-07-20 23:06:21 +00:00
</body>
</html>