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-08-03 16:46:50 +00:00
< title > Lynx Gallery </ title >
2022-08-09 20:09:20 +00:00
<!-- Stylesheets -->
2022-08-11 18:28:52 +00:00
< link rel = " stylesheet " href = " css/main.css " >
2022-08-09 20:09:20 +00:00
< link rel = " stylesheet " href = " css/normalise.css " >
<!-- Google Fonts -->
2022-08-09 13:11:32 +00:00
< link rel = " stylesheet " href = " https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600 " >
< link rel = " stylesheet " href = " https://fonts.googleapis.com/css2?family=Secular+One&display=swap " >
2022-08-03 16:46:50 +00:00
<!-- JQuery -->
2022-08-09 20:09:20 +00:00
< 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-21 14:53:04 +00:00
</ head >
< body >
2022-08-01 13:09:53 +00:00
< ? php
2022-08-07 17:28:21 +00:00
/*
|-------------------------------------------------------------
| Import Required
|-------------------------------------------------------------
| These are common scripts used across all pages of the
| website . At some point I want the whole website to be only
| one index page . But that ' s going to require many many many
| many rewrites and hours of learning ....
|-------------------------------------------------------------
*/
2022-08-07 11:57:13 +00:00
include " ui/required.php " ;
2022-08-10 19:11:44 +00:00
include " ui/nav.php " ;
2022-08-07 11:57:13 +00:00
2022-07-30 10:41:37 +00:00
/*
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
| Get image ID
|-------------------------------------------------------------
| Image ID should be written in the URL of the page as ? id = 69
| If ID cannot be obtained , give error . ID going here ^^
|-------------------------------------------------------------
2022-07-30 10:41:37 +00:00
*/
2022-08-10 19:11:44 +00:00
if ( isset ( $_GET [ 'id' ]) && is_numeric ( $_GET [ 'id' ])) {
2022-08-07 11:57:13 +00:00
// Get all image info
$image = get_image_info ( $conn , $_GET [ 'id' ]);
// Check if image is avalible
if ( isset ( $image [ 'imagename' ])) {
2022-08-10 19:11:44 +00:00
$image_present = True ;
2022-07-30 10:41:37 +00:00
} else {
2022-08-10 19:11:44 +00:00
?>
< script >
sniffleAdd ( 'Woops' , 'Something happened, either image with the ID <?php echo $_GET[' id ']; ?> was deleted or never existed, either way it could not be found!' , 'var(--red)' , '<?php echo $root_dir; ?>assets/icons/cross.svg' );
</ script >
< ? php
$image_present = False ;
2022-07-30 15:01:56 +00:00
}
2022-08-07 11:57:13 +00:00
} else {
2022-08-10 19:11:44 +00:00
?>
< script >
sniffleAdd ( 'Where is da image?' , 'The link you followed seems to be broken, or there was some other error, who knows!' , 'var(--red)' , '<?php echo $root_dir; ?>assets/icons/cross.svg' );
</ script >
< ? php
$image_present = False ;
2022-08-07 11:57:13 +00:00
}
2022-07-30 15:01:56 +00:00
2022-08-07 11:57:13 +00:00
/*
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
2022-08-10 19:11:44 +00:00
| Image verification
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
2022-08-10 19:11:44 +00:00
| Doublechecking if all information on images exists , if yes
| display it , otherwise don ' t display at all or replace with
| blank or filler info
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
2022-08-07 11:57:13 +00:00
*/
2022-08-10 19:11:44 +00:00
if ( $image_present ) {
/*
|-------------------------------------------------------------
| Check user details
|-------------------------------------------------------------
*/
if ( isset ( $image [ 'author' ])) {
// Get all information on the user
$user = get_user_info ( $conn , $image [ 'author' ]);
if ( isset ( $user [ 'username' ])) {
$image_author = $user [ 'username' ];
} else {
$image_author = " Deleted User " ;
}
} else {
$image_author = " No author " ;
}
/*
|-------------------------------------------------------------
| Check if image path is good
|-------------------------------------------------------------
*/
if ( isset ( $image [ 'imagename' ])) {
$image_path = " images/ " . $image [ 'imagename' ];
$image_alt = $image [ 'alt' ];
} else {
$image_path = " assets/no_image.png " ;
$image_alt = " No image could be found, sowwy " ;
}
/*
|-------------------------------------------------------------
| If description not set or empty , replace with filler
|-------------------------------------------------------------
*/
if ( ! isset ( $image_alt ) || empty ( $image_alt )) {
$image_alt = " No description avalible " ;
}
} else {
/*
|-------------------------------------------------------------
| Image was not present
|-------------------------------------------------------------
*/
$image_path = " assets/no_image.png " ;
$image_alt = " No image could be found, sowwy " ;
2022-07-30 15:01:56 +00:00
}
2022-07-30 12:40:30 +00:00
/*
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
| Check user privilge
|-------------------------------------------------------------
2022-07-30 12:40:30 +00:00
*/
2022-08-07 11:57:13 +00:00
if ( image_privilage ( $image [ 'author' ]) || is_admin ( $_SESSION [ 'id' ])) {
$privilaged = True ;
} else {
$privilaged = False ;
2022-07-30 10:41:37 +00:00
}
2022-08-08 11:43:57 +00:00
?>
2022-07-23 07:44:43 +00:00
2022-08-11 18:28:52 +00:00
< div class = " image-container " >
2022-08-07 11:57:13 +00:00
< img class = 'image' id = '<?php echo $image[' id ']; ?>' src = '<?php echo $image_path; ?>' alt = '<?php echo $image_alt; ?>' >
2022-07-21 14:53:04 +00:00
</ div >
2022-08-10 19:11:44 +00:00
< ? php
/*
|-------------------------------------------------------------
| Start of displaying all info on image
|-------------------------------------------------------------
*/
if ( $image_present ) {
?>
2022-08-03 16:46:50 +00:00
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 >
2022-08-10 19:11:44 +00:00
< p >< ? php echo $image_alt ; ?> </p>
2022-07-22 00:21:48 +00:00
</ div >
2022-08-03 16:46:50 +00:00
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-08-10 19:11:44 +00:00
// User
echo " <p>Author: " . $image_author . " </p> " ;
2022-07-25 17:28:55 +00:00
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-08-01 10:20:00 +00:00
if ( strlen ( $image [ 'imagename' ]) > 30 ) {
2022-08-10 19:11:44 +00:00
echo " <p>File Name: " . substr ( $image [ 'imagename' ], 0 , 30 ) . " ...</p> " ;
2022-08-01 10:20:00 +00:00
} else {
echo " <p>File Name: " . $image [ 'imagename' ] . " </p> " ;
}
2022-07-22 13:55:56 +00:00
2022-08-01 10:20:00 +00:00
// File extention
echo " <p>File Type: " . pathinfo ( $image [ 'imagename' ], PATHINFO_EXTENSION ) . " </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
2022-08-01 10:20:00 +00:00
// Image Upload date
2022-08-09 13:11:32 +00:00
echo " <p>Last updated: +0 " . $image [ 'upload' ] . " </p> " ;
2022-08-01 10:20:00 +00:00
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-08-09 10:14:30 +00:00
// Copy image
?>
< script >
function copyLink () {
navigator . clipboard . writeText ( window . location . href );
sniffleAdd ( " Info " , " Link has been copied! " , " var(--green) " , " assets/icons/clipboard-text.svg " );
}
</ script >
< ? php
echo " <button class='btn alert-high space-top-small' onclick='copyLink()'><img class='svg' src='assets/icons/clipboard-text.svg'>Copy image link</button> " ;
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
2022-07-30 15:01:56 +00:00
// Get image tags
if ( isset ( $image [ 'tags' ]) && ! empty ( $image [ 'tags' ])) {
$image_tags_array = explode ( " " , $image [ 'tags' ]);
foreach ( $image_tags_array as $tag ) {
2022-08-08 11:43:57 +00:00
echo " <p class='tag alert-high'><img class='svg' src='assets/icons/tag.svg'> " . $tag . " </p> " ;
2022-07-30 15:01:56 +00:00
}
} else {
echo " <p>No tags present</p> " ;
2022-07-28 21:18:14 +00:00
}
?>
</ div >
</ div >
2022-07-25 17:28:55 +00:00
< ? php
2022-07-30 15:01:56 +00:00
/*
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
| Check if user is privilaged ,
|-------------------------------------------------------------
2022-08-10 19:11:44 +00:00
| If yes , grant them access to the Danger zone , or " the place
| that can fuck things up "
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
2022-07-30 15:01:56 +00:00
*/
2022-07-30 10:41:37 +00:00
if ( $privilaged ) {
2022-08-06 21:14:05 +00:00
?>
<!-- Danger zone -->
< div class = 'danger-zone flex-down default-window' >
< h2 > Danger zone </ h2 >
2022-08-08 11:43:57 +00:00
<!--
|-------------------------------------------------------------
| Delete
|-------------------------------------------------------------
| sus
| I cannot describe the anxiety this gives me . pls help
|-------------------------------------------------------------
-->
2022-08-06 21:14:05 +00:00
< button id = 'deleteButton' class = 'btn alert-low' >< img class = 'svg' src = 'assets/icons/trash.svg' > Delete image </ button >
< script >
2022-08-08 11:43:57 +00:00
$ ( '#deleteButton' ) . click ( function () {
2022-08-07 08:07:18 +00:00
var header = " Are you sure? " ;
var description = " Deleting this image is pernament, there is no going back after this!!!!! " ;
2022-08-08 11:43:57 +00:00
var actionBox = " <form id='deleteConfirm' method='POST'> \
< button id = 'deleteSubmit' class = 'btn alert-low' type = 'submit' >< img class = 'svg' src = 'assets/icons/trash.svg' > Delete image </ button > \
</ form > " ;
2022-08-07 08:07:18 +00:00
flyoutShow ( header , description , actionBox );
2022-08-08 11:43:57 +00:00
$ ( " #deleteConfirm " ) . submit ( function ( event ) {
event . preventDefault ();
var deleteSubmit = $ ( " #deleteSubmit " ) . val ();
2022-08-10 13:05:15 +00:00
$ ( " #sniffle " ) . load ( " app/image/delete_image.php " , {
2022-08-08 11:43:57 +00:00
id : < ? php echo $_GET [ 'id' ]; ?> ,
submit : deleteSubmit
});
});
2022-08-06 21:14:05 +00:00
});
</ script >
2022-08-07 08:07:18 +00:00
<!--
|-------------------------------------------------------------
2022-08-08 11:43:57 +00:00
| Edit Description
2022-08-07 08:07:18 +00:00
|-------------------------------------------------------------
2022-08-08 11:43:57 +00:00
| Most people reading through the code will probably say how
| shit it is . YOU HAVE NO FUCKING CLUE HOW LONG THIS TOOK ME
| TO FIGURE OUT . i hate js .
2022-08-07 17:28:21 +00:00
|-------------------------------------------------------------
2022-08-07 08:07:18 +00:00
-->
< button id = 'descriptionButton' class = 'btn alert-low space-top-small' >< img class = 'svg' src = 'assets/icons/edit.svg' > Edit description </ button >
2022-08-06 21:14:05 +00:00
< script >
2022-08-08 11:43:57 +00:00
$ ( '#descriptionButton' ) . click ( function () {
2022-08-07 08:07:18 +00:00
var header = " Enter new Description/Alt " ;
var description = " Whatcha gonna put in there 👀 " ;
2022-08-07 17:28:21 +00:00
var actionBox = " <form id='descriptionConfirm' action='app/image/edit_description.php' method='POST'> \
2022-08-08 11:43:57 +00:00
< input id = 'descriptionInput' class = 'btn alert-default space-bottom' type = 'text' placeholder = 'Description/Alt for image' > \
< button id = 'descriptionSubmit' class = 'btn alert-low' type = 'submit' >< img class = 'svg' src = 'assets/icons/edit.svg' > Update information </ button > \
2022-08-07 17:28:21 +00:00
</ form > " ;
2022-08-07 08:07:18 +00:00
flyoutShow ( header , description , actionBox );
2022-08-07 17:28:21 +00:00
$ ( " #descriptionConfirm " ) . submit ( function ( event ) {
event . preventDefault ();
var descriptionInput = $ ( " #descriptionInput " ) . val ();
var descriptionSubmit = $ ( " #descriptionSubmit " ) . val ();
2022-08-10 13:05:15 +00:00
$ ( " #sniffle " ) . load ( " app/image/edit_description.php " , {
2022-08-07 17:28:21 +00:00
id : < ? php echo $_GET [ 'id' ]; ?> ,
2022-08-08 11:43:57 +00:00
input : descriptionInput ,
2022-08-07 17:28:21 +00:00
submit : descriptionSubmit
});
2022-08-07 08:07:18 +00:00
});
2022-08-06 21:14:05 +00:00
});
</ script >
2022-08-08 11:43:57 +00:00
<!--
|-------------------------------------------------------------
| Edit Tags
|-------------------------------------------------------------
| Literally no amount of work will get tags / lists to play well
| with SQL so I gave up and made my own shitty system . It
| works but once I re - add the search function this will make
| anyone cry . I am so sorry .
|-------------------------------------------------------------
-->
< button id = 'tagsButton' class = 'btn alert-low space-top-small' >< img class = 'svg' src = 'assets/icons/tag.svg' > Add image tags </ button >
2022-08-06 21:14:05 +00:00
< script >
2022-08-08 11:43:57 +00:00
$ ( '#tagsButton' ) . click ( function () {
2022-08-07 08:07:18 +00:00
var header = " Tags " ;
var description = " Add image tags here! This is still being tested so your tags may be removed later on. Tags ONLY accept, letters, numbers and underscores. Hyphens will be stitched to underscores and spaces will seperate the different tags from eachother " ;
2022-08-08 11:43:57 +00:00
var actionBox = " <form id='tagsConfirm' action='app/image/edit_tags.php' method='POST'> \
< input id = 'tagsInput' class = 'btn alert-default space-bottom' type = 'text' placeholder = 'Tags are seperated by spaces' > \
< button id = 'tagsSubmit' class = 'btn alert-low' type = 'submit' >< img class = 'svg' src = 'assets/icons/edit.svg' > Edit tags </ button > \
</ form > " ;
2022-08-07 08:07:18 +00:00
flyoutShow ( header , description , actionBox );
2022-08-08 11:43:57 +00:00
$ ( " #tagsConfirm " ) . submit ( function ( event ) {
event . preventDefault ();
var tagsInput = $ ( " #tagsInput " ) . val ();
var tagsSubmit = $ ( " #tagsSubmit " ) . val ();
2022-08-10 13:05:15 +00:00
$ ( " #sniffle " ) . load ( " app/image/edit_tags.php " , {
2022-08-08 11:43:57 +00:00
id : < ? php echo $_GET [ 'id' ]; ?> ,
input : tagsInput ,
submit : tagsSubmit
});
});
2022-08-06 21:14:05 +00:00
});
</ script >
2022-08-08 11:43:57 +00:00
<!--
|-------------------------------------------------------------
| Edit Author
|-------------------------------------------------------------
| You must be a super cool person to see this section ; 3
|-------------------------------------------------------------
-->
2022-08-06 21:14:05 +00:00
< ? php
2022-08-01 09:31:23 +00:00
if ( is_admin ( $_SESSION [ 'id' ])) {
2022-08-06 21:14:05 +00:00
?>
2022-08-08 11:43:57 +00:00
< button id = 'authorButton' class = 'btn alert-low space-top-small' >< img class = 'svg' src = 'assets/icons/edit.svg' > Edit author </ button >
< script >
$ ( '#authorButton' ) . click ( function () {
var header = " Who owns the image????? " ;
var description = " Enter ID of image owner " ;
var actionBox = " <form id='authorConfirm' action='app/image/edit_author.php' method='POST'> \
< input id = 'authorInput' class = 'btn alert-default space-bottom' type = 'text' placeholder = 'le author' > \
< button id = 'authorSubmit' class = 'btn alert-low' type = 'submit' >< img class = 'svg' src = 'assets/icons/edit.svg' > Edit author </ button > \
</ form > " ;
flyoutShow ( header , description , actionBox );
$ ( " #authorConfirm " ) . submit ( function ( event ) {
event . preventDefault ();
var authorInput = $ ( " #authorInput " ) . val ();
var authorSubmit = $ ( " #authorSubmit " ) . val ();
2022-08-10 13:05:15 +00:00
$ ( " #sniffle " ) . load ( " app/image/edit_author.php " , {
2022-08-08 11:43:57 +00:00
id : < ? php echo $_GET [ 'id' ]; ?> ,
input : authorInput ,
submit : authorSubmit
});
});
});
</ script >
2022-08-06 21:14:05 +00:00
< ? php
2022-07-30 15:01:56 +00:00
}
2022-07-25 17:28:55 +00:00
echo " </div> " ;
}
2022-08-10 19:11:44 +00:00
/*
|-------------------------------------------------------------
| End of displaying all user info
|-------------------------------------------------------------
*/
}
2022-07-25 17:28:55 +00:00
?>
2022-07-21 14:53:04 +00:00
2022-08-07 08:07:18 +00:00
< ? php include " ui/footer.php " ; ?>
2022-07-21 14:53:04 +00:00
</ body >
</ html >