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-07-25 15:13:26 +00:00
< title > Gallery </ title >
2022-07-21 14:53:04 +00:00
< link rel = " stylesheet " href = " css/master.css " >
2022-07-20 23:06:21 +00:00
< link href = " https://fonts.googleapis.com/css2?family=Rubik " rel = " stylesheet " >
2022-07-22 00:21:48 +00:00
< link rel = " stylesheet " href = " https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600&display=swap " >
< link rel = " stylesheet " href = " https://fonts.googleapis.com/css2?family=Fira+Code:wght@500&display=swap " >
2022-07-20 23:06:21 +00:00
</ head >
< body >
2022-08-01 13:09:53 +00:00
< ? php include ( " ui/header.php " ); ?>
2022-07-25 15:13:26 +00:00
2022-08-01 13:09:53 +00:00
< div class = " alert-banner " >
< ? php
/*
If theres a success in updating the image ,
it ' ll let the user know
*/
// Deletion toast
if ( $_GET [ " del " ] == " true " ) {
echo notify ( " Successfully deleted image: " . $_GET [ 'id' ], " high " );
}
// Account toast
if ( $_GET [ " login " ] == " success " ) {
echo notify ( " O hi " . $_SESSION [ 'username' ], " high " );
}
?>
< script src = 'scripts/alert.js' ></ script >
</ div >
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
header ( " Location:https://superdupersecteteuploadtest.fluffybean.gay?q= " . $tags_string );
}
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-07-24 09:43:54 +00:00
$image_request = mysqli_query ( $conn , " SELECT * FROM swag_table " );
while ( $image = mysqli_fetch_array ( $image_request )) {
2022-07-31 11:50:52 +00:00
// If search is set
if ( isset ( $_GET [ 'q' ]) && ! empty ( $_GET [ 'q' ])) {
// Make search into an array
$search_array = explode ( " " , $_GET [ 'q' ]);
// Get images tags for comparing
$image_tag_array = explode ( " " , $image [ 'tags' ]);
// Compare arrays
$compare_results = array_intersect ( $image_tag_array , $search_array );
if ( count ( $compare_results ) > 0 ) {
// Getting thumbnail
if ( file_exists ( " images/thumbnails/ " . $image [ 'imagename' ])) {
$image_path = " images/thumbnails/ " . $image [ 'imagename' ];
} else {
$image_path = " images/ " . $image [ 'imagename' ];
}
// Image loading
echo " <div class='gallery-item'> " ;
echo " <a href='https://superdupersecteteuploadtest.fluffybean.gay/image.php?id= " . $image [ 'id' ] . " '><img class='gallery-image' loading='lazy' src=' " . $image_path . " ' id=' " . $image [ 'id' ] . " '></a> " ;
echo " </div> " ;
}
2022-07-23 07:44:43 +00:00
} else {
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'> " ;
echo " <a href='https://superdupersecteteuploadtest.fluffybean.gay/image.php?id= " . $image [ 'id' ] . " '><img class='gallery-image' loading='lazy' src=' " . $image_path . " ' id=' " . $image [ 'id' ] . " '></a> " ;
echo " </div> " ;
}
2022-07-20 23:06:21 +00:00
}
?>
</ div >
2022-07-26 12:34:48 +00:00
< ? php
2022-07-31 11:50:52 +00:00
// Must be included with flyout.php
echo " <script src='scripts/flyout.js'></script> " ;
2022-07-26 12:34:48 +00:00
include ( " ui/top.html " );
2022-07-26 13:52:41 +00:00
include ( " ui/footer.php " );
2022-07-26 12:34:48 +00:00
?>
2022-07-20 23:06:21 +00:00
</ body >
</ html >