mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2024-12-28 18:36:22 +00:00
File cleanup in progress
This commit is contained in:
parent
b58588fe85
commit
47aa830771
1
assets/icons/circle-wavy-green.svg
Normal file
1
assets/icons/circle-wavy-green.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#8c977d" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#8c977d" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>
|
After Width: | Height: | Size: 581 B |
1
assets/icons/circle-wavy.svg
Normal file
1
assets/icons/circle-wavy.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#cccccc" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#cccccc" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>
|
After Width: | Height: | Size: 581 B |
110
image.php
110
image.php
|
@ -1,56 +1,3 @@
|
|||
<?php
|
||||
/*
|
||||
Why are you putting all the image checking up here?
|
||||
Wasn't it fine below the header????
|
||||
|
||||
The reason why all this is up here, is so link previews can generate correctly in the header
|
||||
I would rather it all not be up here, but due to variables not being able to be set after already being mentioned
|
||||
(at least to my knowlage)
|
||||
|
||||
I am forced to put ALLL of this up here :c
|
||||
*/
|
||||
|
||||
|
||||
include_once("ui/conn.php");
|
||||
|
||||
// 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>";
|
||||
|
||||
// Replacement "no image" image and description
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
} else {
|
||||
// No ID toast
|
||||
echo "<p class='alert alert-low space-bottom-large'>No ID present</p>";
|
||||
|
||||
// Replacement "no image" image and description
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -64,13 +11,6 @@ if (isset($image['author'])) {
|
|||
<!-- Rich preview -->
|
||||
<meta property="og:type" content="object">
|
||||
<meta property="og:title" content="Only Legs">
|
||||
<?php echo "<meta property='og:image' content='https://superdupersecteteuploadtest.fluffybean.gay/".$image_path."'/>";
|
||||
|
||||
list($meta_width, $meta_height) = getimagesize($image_path);
|
||||
echo "<meta property='og:image:width' content='".$meta_width."'/>";
|
||||
echo "<meta property='og:image:height' content='".$meta_height."'/>";
|
||||
|
||||
echo "<meta property='og:image:alt' content='".$image['alt']."'/>"?>
|
||||
<meta property="og:site_name" content="Only Legs">
|
||||
<meta property="og:url" content="https://superdupersecteteuploadtest.fluffybean.gay">
|
||||
<meta property="og:description" content="Only Legs, a gallery made and hosted by Fluffy">
|
||||
|
@ -79,9 +19,6 @@ if (isset($image['author'])) {
|
|||
<?php
|
||||
include("ui/header.php");
|
||||
|
||||
// Include flyout for extra actions
|
||||
include("ui/flyout.php");
|
||||
|
||||
/*
|
||||
If theres a success in updating the image,
|
||||
it'll let the user know
|
||||
|
@ -92,16 +29,40 @@ if (isset($image['author'])) {
|
|||
echo "<p class='alert alert-default space-bottom-large'>Something went fuckywucky, please try later</p>";
|
||||
}
|
||||
|
||||
// If ID present pull all image data
|
||||
if (isset($_GET['id'])) {
|
||||
$image = get_image_info($conn, $_GET['id']);
|
||||
|
||||
/*
|
||||
Check if the user is an admin session id = 1
|
||||
Or the owner of the image, image author == session id
|
||||
// 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>";
|
||||
|
||||
This may not be the best system of doing this, but much better than not having it at all
|
||||
I plan on adding an array of privilaged users that user with the id of 1 can modify,
|
||||
sort of like a mod/admin list of users
|
||||
*/
|
||||
if (isset($_SESSION['id']) && $image['author'] == $_SESSION['id'] || $_SESSION['id'] == 1) {
|
||||
// Replacement "no image" image and description
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
} else {
|
||||
// No ID toast
|
||||
echo "<p class='alert alert-low space-bottom-large'>No ID present</p>";
|
||||
|
||||
// Replacement "no image" image and description
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
|
||||
// Get all user details
|
||||
if (isset($image['author'])) {
|
||||
$user = get_user_info($conn, $image['author']);
|
||||
}
|
||||
|
||||
// Check user privilge
|
||||
if (image_privilage($image['author']) || is_admin($_SESSION['id'])) {
|
||||
$privilaged = True;
|
||||
} else {
|
||||
$privilaged = False;
|
||||
|
@ -248,7 +209,7 @@ if (isset($image['author'])) {
|
|||
/*
|
||||
Description athor
|
||||
*/
|
||||
if (isset($_POST['author_flyout']) && $_SESSION['id'] == 1) {
|
||||
if (isset($_POST['author_flyout']) && is_admin($_SESSION['id'])) {
|
||||
$header = "Who owns the image?????";
|
||||
$content = "Enter ID of image owner";
|
||||
$action = "<form class='flex-down between' method='POST' enctype='multipart/form-data'>
|
||||
|
@ -261,7 +222,7 @@ if (isset($image['author'])) {
|
|||
/*
|
||||
Author confirm
|
||||
*/
|
||||
if (isset($_POST['author_confirm']) && $_SESSION['id'] == 1) {
|
||||
if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) {
|
||||
// Unset all the variables, needed by flyout
|
||||
unset($header, $content, $action);
|
||||
|
||||
|
@ -352,7 +313,6 @@ if (isset($image['author'])) {
|
|||
} else {
|
||||
echo "<p>No tags present</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -385,7 +345,7 @@ if (isset($image['author'])) {
|
|||
</form>";
|
||||
|
||||
// Edit authro
|
||||
if ($_SESSION['id'] == 1) {
|
||||
if (is_admin($_SESSION['id'])) {
|
||||
echo "<form method='POST'>
|
||||
<button class='btn alert-low space-top-small flyout-display' type='submit' name='author_flyout'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
|
||||
</form>";
|
||||
|
|
15
index.php
15
index.php
|
@ -13,9 +13,6 @@
|
|||
<?php
|
||||
include("ui/header.php");
|
||||
|
||||
// Include flyout for extra actions
|
||||
include("ui/flyout.php");
|
||||
|
||||
// Deletion toast
|
||||
if ($_GET["del"] == "true") {
|
||||
echo "<p class='alert alert-high space-bottom'>Successfully deleted image: ".$_GET['id']."</p>";
|
||||
|
@ -44,18 +41,6 @@
|
|||
// Unset all the variables, needed by flyout
|
||||
unset($header, $content, $action);
|
||||
|
||||
// Clean tags before adding
|
||||
function clean($string) {
|
||||
// Change to lowercase
|
||||
$string = strtolower($string);
|
||||
// Replace hyphens
|
||||
$string = str_replace('-', '_', $string);
|
||||
// Regex
|
||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||
// Return string
|
||||
return preg_replace('/ +/', ' ', $string);
|
||||
}
|
||||
|
||||
// Clean input
|
||||
$tags_string = clean(trim($_POST['search']));
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
function flyout($flyout_header, $flyout_content, $flyout_action) {
|
||||
// Used for background dimming
|
||||
echo "<div class='flyout-dim'></div>";
|
||||
// Div Start
|
||||
echo "<div class='flyout flex-down default-window between'>";
|
||||
|
||||
// Header for the flyout, must be included
|
||||
if (isset($flyout_header) && !empty($flyout_header)) {
|
||||
echo "<h2 class='space-bottom'>".$flyout_header."</h2>";
|
||||
}
|
||||
// Flyout content, must be included!!!!
|
||||
if (isset($flyout_content) && !empty($flyout_content)) {
|
||||
echo "<p class='space-bottom'>".$flyout_content."</p>";
|
||||
}
|
||||
// Flyout button, not required so must need more information when added
|
||||
if (isset($flyout_action) && !empty($flyout_action)) {
|
||||
echo $flyout_action;
|
||||
}
|
||||
|
||||
// Exit button + Div End
|
||||
echo "<button class='btn alert-default space-top flyout-close'>Close</button>
|
||||
</div>";
|
||||
}
|
||||
?>
|
154
ui/functions.php
Normal file
154
ui/functions.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
/*
|
||||
Get full image info from database
|
||||
|
||||
Returns array with image info
|
||||
*/
|
||||
function get_image_info($conn, $id) {
|
||||
// Setting SQL query
|
||||
$sql = "SELECT * FROM swag_table WHERE id = ".$id;
|
||||
// Getting results
|
||||
$query = mysqli_query($conn, $sql);
|
||||
// Fetching associated info
|
||||
$image_array = mysqli_fetch_assoc($query);
|
||||
|
||||
return($image_array);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Get full user info from database
|
||||
|
||||
Returns array with user info
|
||||
*/
|
||||
function get_user_info($conn, $id) {
|
||||
// Setting SQL query
|
||||
$sql = "SELECT * FROM users WHERE id = ".$id;
|
||||
// Getting results
|
||||
$query = mysqli_query($conn, $sql);
|
||||
// Fetching associated info
|
||||
$user_array = mysqli_fetch_assoc($query);
|
||||
|
||||
return($user_array);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Clean up long text input and turn into an array for tags
|
||||
|
||||
Returns clean string of words with equal white space between it
|
||||
*/
|
||||
function tag_clean($string) {
|
||||
// Replace hyphens
|
||||
$string = str_replace('-', '_', $string);
|
||||
// Regex
|
||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||
// Change to lowercase
|
||||
$string = strtolower($string);
|
||||
// Removing extra spaces
|
||||
$string = preg_replace('/ +/', ' ', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check if user is loggedin
|
||||
|
||||
Returns True if user is
|
||||
Returns False if user is NOT
|
||||
*/
|
||||
function loggedin() {
|
||||
if (isset($_SESSION["loggedin"]) == true && $_SESSION["loggedin"] == true) {
|
||||
return True;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check if user is image owner
|
||||
|
||||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
*/
|
||||
function image_privilage($id) {
|
||||
$session_id = $_SESSION['id'];
|
||||
if (isset($session_id) || !empty($session_id)) {
|
||||
if ($session_id == $id) {
|
||||
return True;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check if user is admin
|
||||
|
||||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
*/
|
||||
function is_admin($id) {
|
||||
if (isset($id) || !empty($id)) {
|
||||
if ($id == 1) {
|
||||
return True;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Takes in max 3 min 2 inputs:
|
||||
|
||||
Header is displayed ontop of the flyout
|
||||
Takes in text input
|
||||
|
||||
Description is displayed in the center of the flyout
|
||||
Takes in text input
|
||||
|
||||
Action is displayed above the cancel button
|
||||
Takes in any HTML input
|
||||
|
||||
Returns nothing but must include:
|
||||
<script src='scripts/flyout.js'></script>
|
||||
At the bottom of the HTML document
|
||||
*/
|
||||
function flyout($header, $content, $action) {
|
||||
// Used for background dimming
|
||||
echo "<div class='flyout-dim'></div>";
|
||||
// Div Start
|
||||
echo "<div class='flyout flex-down default-window between'>";
|
||||
|
||||
// Header for the flyout, must be included
|
||||
if (isset($header) && !empty($header)) {
|
||||
echo "<h2 class='space-bottom'>".$header."</h2>";
|
||||
} else {
|
||||
echo "<h2 class='space-bottom'>Header</h2>";
|
||||
}
|
||||
|
||||
// Flyout content, must be included!!!!
|
||||
if (isset($content) && !empty($content)) {
|
||||
echo "<p class='space-bottom'>".$content."</p>";
|
||||
} else {
|
||||
echo "<h2 class='space-bottom'>Description</h2>";
|
||||
}
|
||||
|
||||
// Flyout button, not required so must need more information when added
|
||||
if (isset($action) && !empty($action)) {
|
||||
echo $action;
|
||||
}
|
||||
|
||||
// Exit button + Div End
|
||||
echo "<button class='btn alert-default space-top flyout-close'>Close</button>
|
||||
</div>";
|
||||
}
|
||||
?>
|
|
@ -1,6 +1,15 @@
|
|||
<?php
|
||||
// Include required files by every page on header
|
||||
session_start();
|
||||
if (is_dir("ui/")) {
|
||||
include("ui/conn.php");
|
||||
include_once("ui/functions.php");
|
||||
} else {
|
||||
include("../ui/conn.php");
|
||||
include_once("../ui/functions.php");
|
||||
}
|
||||
|
||||
// Check which directory icons are in
|
||||
if (is_dir("assets/icons/")) {
|
||||
$dir = "assets/icons/";
|
||||
} else {
|
||||
|
@ -19,7 +28,7 @@ if (is_dir("assets/icons/")) {
|
|||
echo "<a class='btn alert-default flyout-display' href='https://superdupersecteteuploadtest.fluffybean.gay?srch=show'><img class='svg' src='".$dir."binoculars.svg'><span class='nav-hide'>Search</span></a>";
|
||||
echo "<hr>";
|
||||
|
||||
if (isset($_SESSION["username"])) {
|
||||
if (loggedin()) {
|
||||
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/upload.php'><img class='svg' src='".$dir."upload.svg'><span class='nav-hide'>Upload</span></a>";
|
||||
echo "<hr>";
|
||||
echo "<a class='btn alert-default' href='https://superdupersecteteuploadtest.fluffybean.gay/account/account.php'><img class='svg' src='".$dir."user-circle.svg'><span class='nav-hide'>".substr($_SESSION["username"], 0, 15)."</span></a>";
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
include_once("ui/conn.php");
|
||||
|
||||
// Check if user is logged in
|
||||
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
||||
if (loggedin()) {
|
||||
// User is logged in
|
||||
} else {
|
||||
$error = "You must be logged in to upload images";
|
||||
|
|
Loading…
Reference in a new issue