2022-07-21 14:53:04 +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 " >
< link href = " https://fonts.googleapis.com/css2?family=Rubik " rel = " stylesheet " >
2022-07-23 14:03:11 +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-21 14:53:04 +00:00
</ head >
< body >
< ? php
2022-07-23 07:44:43 +00:00
include ( " ui/header.php " );
include_once ( " ui/conn.php " );
2022-07-21 14:53:04 +00:00
2022-07-24 09:43:54 +00:00
// Update toast
if ( $_GET [ " update " ] == " success " ) {
2022-07-25 15:13:26 +00:00
echo " <p class='alert alert-high space-bottom-large'>Information updated</p> " ;
2022-07-27 11:46:10 +00:00
} elseif ( $_GET [ " update " ] == " skip " ) {
echo " <p class='alert alert-default space-bottom-large'>No alt, skip</p> " ;
2022-07-24 09:43:54 +00:00
}
2022-07-28 10:35:57 +00:00
// If ID present pull all image data
if ( isset ( $_GET [ 'id' ])) {
$get_image = " SELECT * FROM swag_table WHERE id = " . $_GET [ 'id' ];
$image_results = mysqli_query ( $conn , $get_image );
$image = mysqli_fetch_assoc ( $image_results );
// Check if image is avalible
if ( isset ( $image [ 'imagename' ])) {
// Display image
$image_path = " images/ " . $image [ 'imagename' ];
$image_alt = $image [ 'alt' ];
} else {
// ID not avalible toast
echo " <p class='alert alert-low space-bottom-large'>Could not find image with ID: " . $_GET [ 'id' ] . " </p> " ;
2022-07-25 17:28:55 +00:00
2022-07-28 10:35:57 +00:00
// Replacement "no image" image and description
$image_path = " assets/no_image.png " ;
$image_alt = " No image could be found, sowwy " ;
}
} else {
2022-07-24 09:43:54 +00:00
// No ID toast
2022-07-25 15:13:26 +00:00
echo " <p class='alert alert-low space-bottom-large'>No ID present</p> " ;
2022-07-24 09:43:54 +00:00
2022-07-23 14:03:11 +00:00
// Replacement "no image" image and description
2022-07-23 07:44:43 +00:00
$image_path = " assets/no_image.png " ;
$image_alt = " No image could be found, sowwy " ;
}
2022-07-28 10:35:57 +00:00
// Get all user details
if ( isset ( $image [ 'author' ])) {
$get_user = " SELECT * FROM users WHERE id = " . $image [ 'author' ];
$user_results = mysqli_query ( $conn , $get_user );
$user = mysqli_fetch_assoc ( $user_results );
} else
2022-07-23 07:44:43 +00:00
?>
< div class = " image-container " >
2022-07-28 10:35:57 +00:00
< ? php
// Displaying image
echo " <img class='image' id=' " . $image [ 'id' ] . " ' src=' " . $image_path . " ' alt=' " . $image_alt . " '> " ;
?>
2022-07-21 14:53:04 +00:00
</ div >
2022-07-27 11:46:10 +00:00
< div class = " image-description default-window " >
2022-07-22 00:21:48 +00:00
< h2 > Description </ h2 >
< ? php
2022-07-22 13:55:56 +00:00
// Image Description/Alt
2022-07-28 21:18:14 +00:00
if ( isset ( $image_alt ) && ! empty ( $image_alt )) {
2022-07-23 07:44:43 +00:00
echo " <p> " . $image_alt . " </p> " ;
2022-07-28 10:35:57 +00:00
} else {
echo " <p>No description provided</p> " ;
2022-07-22 13:55:56 +00:00
}
2022-07-22 00:21:48 +00:00
?>
</ div >
2022-07-27 11:46:10 +00:00
< div class = " image-detail flex-down default-window " >
2022-07-22 00:21:48 +00:00
< h2 > Details </ h2 >
2022-07-21 14:53:04 +00:00
< ? php
2022-07-25 17:28:55 +00:00
// Image ID
if ( isset ( $image [ 'author' ])) {
2022-07-28 10:35:57 +00:00
if ( isset ( $user [ 'username' ])) {
echo " <p>Author: " . $user [ 'username' ] . " </p> " ;
} else {
echo " <p>Author: Deleted User</p> " ;
}
2022-07-25 17:28:55 +00:00
} else {
echo " <p>Author: No author</p> " ;
}
2022-07-22 13:55:56 +00:00
// Image ID
2022-07-21 14:53:04 +00:00
echo " <p>ID: " . $image [ 'id' ] . " </p> " ;
2022-07-22 13:55:56 +00:00
// File name
2022-07-21 14:53:04 +00:00
echo " <p>File Name: " . $image [ 'imagename' ] . " </p> " ;
2022-07-22 13:55:56 +00:00
// Image Upload date
2022-07-26 11:33:28 +00:00
echo " <p>Last updated: " . $image [ 'upload' ] . " (+0)</p> " ;
2022-07-22 13:55:56 +00:00
// Image resolution
list ( $width , $height ) = getimagesize ( $image_path );
echo " <p>Image resolution: " . $width . " x " . $height . " </p> " ;
2022-07-23 14:03:11 +00:00
// Image download
echo " <a class='btn alert-high space-top' href='images/ " . $image [ 'imagename' ] . " ' download=' " . $image [ 'imagename' ] . " '><img class='svg' src='assets/icons/download.svg'>Download image</a> " ;
2022-07-29 15:41:05 +00:00
// Flyout test button
2022-07-21 14:53:04 +00:00
?>
2022-07-29 15:41:05 +00:00
2022-07-21 14:53:04 +00:00
</ div >
2022-07-28 21:18:14 +00:00
< div class = " tags-root default-window " >
< h2 > Tags </ h2 >
2022-07-29 12:53:36 +00:00
< div class = " tags flex-left " >
2022-07-28 21:18:14 +00:00
< ? php
function clean ( $string ) {
$string = str_replace ( '-' , '_' , $string );
$string = preg_replace ( '/[^A-Za-z0-9\_ ]/' , '' , $string );
return preg_replace ( '/ +/' , ' ' , $string );
}
$tags_string = " This is a test of ta.gs and their s//ystem_of_ignoring ran!!dom characters BUT THIS DOES $ $ $ $ $ $ .NT WORK YET!!!! " ;
$tags_string = strtolower ( $tags_string );
$tags_string = clean ( $tags_string );
$image_tags_array = explode ( " " , $tags_string );
foreach ( $image_tags_array as $tag ) {
echo " <p class='tag alert-high'> " . $tag . " </p> " ;
}
?>
</ div >
</ div >
2022-07-25 17:28:55 +00:00
< ? php
2022-07-28 10:35:57 +00:00
// Check if user is admin or the owner of image, if yes, display the edit and delete div
2022-07-25 17:28:55 +00:00
if ( isset ( $_SESSION [ 'id' ]) && $image [ 'author' ] == $_SESSION [ 'id' ] || $_SESSION [ 'id' ] == 1 ) {
2022-07-27 11:46:10 +00:00
// Deleting image
2022-07-21 18:42:03 +00:00
if ( isset ( $_POST [ 'delete' ])) {
2022-07-27 11:46:10 +00:00
// Delete from table
$image_delete_request = " DELETE FROM swag_table WHERE id = " . $image [ 'id' ];
$image_delete = mysqli_query ( $conn , $image_delete_request );
if ( $image_delete ) {
// See if image is in the directory
if ( is_file ( " images/ " . $image [ 'imagename' ])) {
unlink ( " images/ " . $image [ 'imagename' ]);
}
// Delete thumbnail if exitsts
if ( is_file ( " images/thumbnails/ " . $image [ 'imagename' ])) {
unlink ( " images/thumbnails/ " . $image [ 'imagename' ]);
2022-07-21 14:53:04 +00:00
}
2022-07-27 11:46:10 +00:00
header ( " Location:index.php?del=true&id= " . $image [ 'id' ]);
2022-07-23 07:44:43 +00:00
} else {
2022-07-27 11:46:10 +00:00
$error = " Could not delete image " ;
2022-07-21 14:53:04 +00:00
}
}
2022-07-23 09:37:12 +00:00
2022-07-29 15:41:05 +00:00
// Danger zone
echo " <div class='danger-zone flex-down default-window'>
< h2 > Danger zone </ h2 > " ;
// Delete button
?>
< button class = " btn alert-low space-top flyout-display " onClick = " <?php
$flyout_header = " Are you sure? " ;
$flyout_content = " Deleting this image is pernament, there is no going back after this!!!!! " ;
$flyout_interaction = " <form class='detail' method='POST' enctype='multipart/form-data'>
< button class = 'btn alert-low' type = 'submit' name = 'delete' value = '".$image[' id ']."' >< img class = 'svg' src = 'assets/icons/trash.svg' > Delete image </ button >
</ form > " ;
?> ">Delete image</button>
< ? php
2022-07-27 11:46:10 +00:00
// Edit image button
2022-07-28 21:18:14 +00:00
echo " <a class='btn alert-low space-top-small' href='https://superdupersecteteuploadtest.fluffybean.gay/edit.php?id= " . $image [ 'id' ] . " '><img class='svg' src='assets/icons/edit.svg'>Modify image content</a> " ;
2022-07-25 17:28:55 +00:00
echo " </div> " ;
}
?>
2022-07-21 14:53:04 +00:00
2022-07-29 15:41:05 +00:00
< button class = " btn alert-high space-top flyout-display " onClick = " <?php
$flyout_header = " Sus " ;
$flyout_content = " This is a test UwU. You are currently viewing image: " . $_GET [ 'id' ];
$flyout_interaction = " <a class='btn alert-high'>This button does nothing!</a> <a class='btn alert-low space-top-small'>I'm another button, but scawwy</a> " ;
?> ">Test button</button>
2022-07-26 12:34:48 +00:00
< ? php
2022-07-29 12:53:36 +00:00
include_once ( " ui/flyout.php " );
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-21 14:53:04 +00:00
</ body >
</ html >