mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2024-12-29 10:56:12 +00:00
Reformatting codew
This commit is contained in:
parent
19e945d1cd
commit
d6c9951233
|
@ -21,7 +21,7 @@
|
||||||
margin: 0.5rem; padding: 0;
|
margin: 0.5rem; padding: 0;
|
||||||
|
|
||||||
/*max-width: 232.5px; max-height: 232.5px;*/
|
/*max-width: 232.5px; max-height: 232.5px;*/
|
||||||
height: auto; max-width: 315px;
|
height: auto; max-width: 350px;
|
||||||
|
|
||||||
background-color: var(--bg-2);
|
background-color: var(--bg-2);
|
||||||
border-radius: var(--rad);
|
border-radius: var(--rad);
|
||||||
|
|
|
@ -42,3 +42,12 @@ nav hr {
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 400px) {
|
||||||
|
.nav-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.nav-links a .svg {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
53
edit.php
53
edit.php
|
@ -14,34 +14,46 @@
|
||||||
include("ui/header.php");
|
include("ui/header.php");
|
||||||
include("ui/conn.php");
|
include("ui/conn.php");
|
||||||
|
|
||||||
if (isset($_POST['id'])) {
|
// Check if user is logged in
|
||||||
// Getting all image info from table
|
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
||||||
$get_image = "SELECT * FROM swag_table WHERE id = ".$_POST['id'];
|
// Get post ID from button
|
||||||
$image_results = mysqli_query($conn, $get_image);
|
if (isset($_POST['id'])) {
|
||||||
$image = mysqli_fetch_assoc($image_results);
|
// Getting all image info from table
|
||||||
|
$get_image = "SELECT * FROM swag_table WHERE id = ".$_POST['id'];
|
||||||
|
$image_results = mysqli_query($conn, $get_image);
|
||||||
|
$image = mysqli_fetch_assoc($image_results);
|
||||||
|
|
||||||
// Checking if user has edit rights
|
// Check if user owns image
|
||||||
if (isset($_SESSION['id']) && $image['author'] == $_SESSION['id'] || $_SESSION['id'] == 1) {
|
if (isset($_SESSION['id']) && $image['author'] == $_SESSION['id'] || $_SESSION['id'] == 1) {
|
||||||
if (isset($_POST['alt'])) {
|
// If no errors
|
||||||
$sql = $conn->prepare("UPDATE swag_table SET alt=? WHERE id=?");
|
if (empty($error)) {
|
||||||
$sql->bind_param("si", $alt, $id);
|
// getting ready forSQL asky asky
|
||||||
|
$sql = "UPDATE swag_table SET alt=? WHERE id=?";
|
||||||
|
|
||||||
$alt = $_POST['alt'];
|
// Checking if databse is doing ok
|
||||||
$id = $_POST['id'];
|
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||||
|
mysqli_stmt_bind_param($stmt, "si", $param_alt, $param_id);
|
||||||
|
|
||||||
if ($sql->execute()) {
|
// Setting parameters
|
||||||
header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$_POST['id']."&update=success");
|
$param_alt = $_POST['alt'];
|
||||||
} else {
|
$param_id = $_POST['id'];
|
||||||
$error = "Something fuckywucky";
|
|
||||||
|
// Attempt to execute the prepared statement
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$_POST['id']."&update=success");
|
||||||
|
} else {
|
||||||
|
$error = "Something went fuckywucky, please try later";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = "No description/alt, pls give";
|
$error = "You do not have edit rights";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$error = "You do not have edit rights";
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$error = "You must be logged in to edit images";
|
||||||
|
//header("Location: https://superdupersecteteuploadtest.fluffybean.gay");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="edit-root">
|
<div class="edit-root">
|
||||||
|
@ -51,7 +63,6 @@
|
||||||
<input class="btn alert-default space-bottom-large" type="text" name="alt" placeholder="Description/Alt for image">
|
<input class="btn alert-default space-bottom-large" type="text" name="alt" placeholder="Description/Alt for image">
|
||||||
<?php echo "<button class='btn alert-default' type='submit' name='id' value=".$_GET["id"]."><img class='svg' src='assets/icons/edit.svg'>Update information</button>"; ?>
|
<?php echo "<button class='btn alert-default' type='submit' name='id' value=".$_GET["id"]."><img class='svg' src='assets/icons/edit.svg'>Update information</button>"; ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($error)) {
|
if (isset($error)) {
|
||||||
echo "<p class='alert alert-low space-top'>".$error."</p>";
|
echo "<p class='alert alert-low space-top'>".$error."</p>";
|
||||||
|
|
12
image.php
12
image.php
|
@ -53,6 +53,13 @@
|
||||||
// Display image
|
// Display image
|
||||||
$image_path = "images/".$image['imagename'];
|
$image_path = "images/".$image['imagename'];
|
||||||
$image_alt = $image['alt'];
|
$image_alt = $image['alt'];
|
||||||
|
|
||||||
|
// Add image view
|
||||||
|
if (empty($image['views'])) {
|
||||||
|
//$conn->query("UPDATE swag_table SET views=1 WHERE id=".$image['id']);
|
||||||
|
} else {
|
||||||
|
//$conn->query("UPDATE swag_table SET views=views+1 WHERE id=".$image['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -83,6 +90,9 @@
|
||||||
echo "<p>Author: No author</p>";
|
echo "<p>Author: No author</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Views
|
||||||
|
//echo "<p>Views: ".$image['views']."</p>";
|
||||||
|
|
||||||
// Image ID
|
// Image ID
|
||||||
echo "<p>ID: ".$image['id']."</p>";
|
echo "<p>ID: ".$image['id']."</p>";
|
||||||
|
|
||||||
|
@ -90,7 +100,7 @@
|
||||||
echo "<p>File Name: ".$image['imagename']."</p>";
|
echo "<p>File Name: ".$image['imagename']."</p>";
|
||||||
|
|
||||||
// Image Upload date
|
// Image Upload date
|
||||||
echo "<p>Upload Date: ".$image['upload']."</p>";
|
echo "<p>Last updated: ".$image['upload']." (+0)</p>";
|
||||||
|
|
||||||
// Image resolution
|
// Image resolution
|
||||||
list($width, $height) = getimagesize($image_path);
|
list($width, $height) = getimagesize($image_path);
|
||||||
|
|
|
@ -108,6 +108,7 @@
|
||||||
echo "<p class='alert alert-high space-top'>".$success."</p>";
|
echo "<p class='alert alert-high space-top'>".$success."</p>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<a class='btn alert-default space-top-large' href='https://superdupersecteteuploadtest.fluffybean.gay/signup.php'><img class="svg" src="assets/icons/sign-in.svg">Need an account? Sign up!</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php include("ui/footer.php"); ?>
|
<?php include("ui/footer.php"); ?>
|
||||||
|
|
|
@ -129,7 +129,6 @@
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
||||||
<a class='btn alert-default space-top-large' href='https://superdupersecteteuploadtest.fluffybean.gay/login.php'><img class="svg" src="assets/icons/sign-in.svg">Got an account? Login!</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php include("ui/footer.php"); ?>
|
<?php include("ui/footer.php"); ?>
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
<h3>Fluffys Amazing Gallery!</h3>
|
<h3>Fluffys Amazing Gallery!</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-links flex-left">
|
<div class="nav-links flex-left">
|
||||||
<a class="btn alert-default" href="https://superdupersecteteuploadtest.fluffybean.gay"><img class="svg" src="assets/icons/house.svg">Home</a>
|
<a class="btn alert-default" href="https://superdupersecteteuploadtest.fluffybean.gay"><img class="svg" src="assets/icons/house.svg"><span class="nav-hide">Home</span></a>
|
||||||
<hr>
|
<hr>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_SESSION["username"])) {
|
if (isset($_SESSION["username"])) {
|
||||||
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/upload.php'><img class='svg' src='assets/icons/upload.svg'>Upload</a>";
|
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/account.php'><img class='svg' src='assets/icons/user-circle.svg'>".$_SESSION["username"]."</a>";
|
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/account.php'><img class='svg' src='assets/icons/user-circle.svg'><span class='nav-hide'>".$_SESSION["username"]."</span></a>";
|
||||||
} else {
|
} else {
|
||||||
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/signup.php'><img class='svg' src='assets/icons/user-circle-plus.svg'>Sign Up</a>";
|
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/login.php'><img class='svg' src='assets/icons/user-circle-plus.svg'><span class='nav-hide'>Login</span></a>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
74
upload.php
74
upload.php
|
@ -16,50 +16,51 @@
|
||||||
|
|
||||||
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
||||||
if (isset($_POST['upload'])) {
|
if (isset($_POST['upload'])) {
|
||||||
// Get image name
|
// Setting image up for upload
|
||||||
$image_name = $_FILES['image']['name'];
|
$image_name = $_FILES['image']['name'];
|
||||||
|
if (isset($image_name)) {
|
||||||
// Get alt text
|
|
||||||
if (empty($_POST['alt'])) {
|
|
||||||
$get_alt_text = "No description provided";
|
|
||||||
} else {
|
|
||||||
$get_alt_text = $_POST['alt'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// If image present, continue
|
|
||||||
if (!empty($image_name)) {
|
|
||||||
// Set file path for image upload
|
// Set file path for image upload
|
||||||
$image_basename = basename($image_name);
|
$image_basename = basename($image_name);
|
||||||
$image_path = "images/".$image_basename;
|
$image_path = "images/".$image_basename;
|
||||||
|
|
||||||
// Prepare sql for destruction and filtering the sus
|
// Check if errors occured
|
||||||
$sql = $conn->prepare("INSERT INTO swag_table (imagename, alt, author) VALUES (?, ?, ?)");
|
if (empty($error)) {
|
||||||
$sql->bind_param("sss", $image_name, $get_alt_text, $user_id);
|
// Prepare sql for destruction and filtering the sus
|
||||||
|
$sql = "INSERT INTO swag_table (imagename, alt, author) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
$user_id = $_SESSION["id"];
|
// Can contact database?
|
||||||
|
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||||
|
// Bind the smelly smelly
|
||||||
|
mysqli_stmt_bind_param($stmt, "sss", $param_image_name, $param_alt_text, $param_user_id);
|
||||||
|
|
||||||
// Uploading image to Table
|
// Setting up parameters
|
||||||
$sql->execute();
|
$param_image_name = $image_name;
|
||||||
|
$param_alt_text = $_POST['alt'];
|
||||||
|
$param_user_id = $_SESSION["id"];
|
||||||
|
|
||||||
// Checking if image uploaded
|
// Attempt to execute the prepared statement
|
||||||
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
// Make thumbnail
|
// Move files onto server
|
||||||
$image_thumbnail = new Imagick($image_path);
|
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
|
||||||
// Get image format
|
// Make thumbnail
|
||||||
$image_format = $image_thumbnail->getImageFormat();
|
$image_thumbnail = new Imagick($image_path);
|
||||||
// If image is gif
|
$image_format = $image_thumbnail->getImageFormat();
|
||||||
if ($image_format == 'GIF') {
|
// If image is GIF
|
||||||
$image_thumbnail = $image_thumbnail->coalesceImages();
|
if ($image_format == 'GIF') {
|
||||||
|
$image_thumbnail = $image_thumbnail->coalesceImages();
|
||||||
|
}
|
||||||
|
// Resize image
|
||||||
|
$image_thumbnail->resizeImage(300,null,null,1,null);
|
||||||
|
$image_thumbnail->writeImage("images/thumbnails/".$image_basename);
|
||||||
|
|
||||||
|
$success = "Your Image uploaded successfully!";
|
||||||
|
} else {
|
||||||
|
$error = "F, Upload failed";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Something went fuckywucky, please try later";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Resize image
|
|
||||||
$image_thumbnail->resizeImage(300,null,null,1,null);
|
|
||||||
// Save image
|
|
||||||
$image_thumbnail->writeImage("images/thumbnails/".$image_basename);
|
|
||||||
|
|
||||||
$success = "Your Image uploaded successfully!";
|
|
||||||
} else {
|
|
||||||
// Could not move images to folder
|
|
||||||
$error = "F, Upload failed";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No image present
|
// No image present
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = "You must be logged in to upload images";
|
$error = "You must be logged in to upload images";
|
||||||
header("Location: https://superdupersecteteuploadtest.fluffybean.gay");
|
//header("Location: https://superdupersecteteuploadtest.fluffybean.gay");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -80,7 +81,6 @@
|
||||||
<input class="btn alert-default space-bottom-large" type="text" name="alt" placeholder="Description/Alt for image">
|
<input class="btn alert-default space-bottom-large" type="text" name="alt" placeholder="Description/Alt for image">
|
||||||
<button class="btn alert-default" type="submit" name="upload"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
|
<button class="btn alert-default" type="submit" name="upload"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($error)) {
|
if (isset($error)) {
|
||||||
echo "<p class='alert alert-low space-top'>".$error."</p>";
|
echo "<p class='alert alert-low space-top'>".$error."</p>";
|
||||||
|
|
Loading…
Reference in a new issue