mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-05-29 23:03:12 +00:00
Code cleanup in progress
This commit is contained in:
parent
6de757215f
commit
5a591c59bc
13 changed files with 339 additions and 348 deletions
|
@ -1,3 +1,5 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
|
@ -5,12 +7,8 @@
|
|||
<?php require_once __DIR__."/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
?>
|
||||
<?php require_once __DIR__."/ui/nav.php"; ?>
|
||||
|
||||
<div class="about-root">
|
||||
<h1><?php echo $user_settings['website_name']; ?></h1>
|
||||
|
|
13
account.php
13
account.php
|
@ -1,3 +1,5 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
|
@ -7,14 +9,13 @@
|
|||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<script>
|
||||
console.log(". . /|/| . . . . . . .\n\
|
||||
.. /0 0 \\ . . . . . ..\n\
|
||||
(III% . \\________, . .\n\
|
||||
.. .\\_, .%###%/ \\'\\,..\n\
|
||||
. . . .||#####| |'\\ \\.\n\
|
||||
.. . . ||. . .|/. .\\V.\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . cc/ . .cc/ . . .");
|
||||
</script>
|
|
@ -26,7 +26,7 @@
|
|||
"The world will not be destroyed by those who do evil, but by those who watch them and do nothing."
|
||||
],
|
||||
"license":"GPL 3.0",
|
||||
"version": "22.09.20",
|
||||
"version": "22.09.21",
|
||||
"user_name": "Michal",
|
||||
"is_testing": "true",
|
||||
"upload_max": "20"
|
||||
|
|
|
@ -9,12 +9,4 @@
|
|||
|-------------------------------------------------------------
|
||||
*/
|
||||
$user_import = file_get_contents(__DIR__."/manifest.json");
|
||||
$user_settings = json_decode($user_import, true);
|
||||
|
||||
foreach ($user_settings->data as $website) {
|
||||
foreach ($website->debug as $debug) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$debug = $user_settings["website"]["debug"];
|
||||
$user_settings = json_decode($user_import, true);
|
15
css/main.css
15
css/main.css
|
@ -217,7 +217,8 @@ nav .btn {
|
|||
margin: 0.25rem;
|
||||
padding: 0;
|
||||
height: auto;
|
||||
max-width: calc(33.33% - 0.5rem);
|
||||
max-width: calc(20% - 0.5rem);
|
||||
min-width: calc(20% - 0.5rem);
|
||||
background-color: #151515;
|
||||
border-radius: -0.25rem;
|
||||
position: relative;
|
||||
|
@ -236,6 +237,18 @@ nav .btn {
|
|||
padding-bottom: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.gallery-item {
|
||||
max-width: calc(25% - 0.5rem);
|
||||
min-width: calc(25% - 0.5rem);
|
||||
}
|
||||
}
|
||||
@media (max-width: 550px) {
|
||||
.gallery-item {
|
||||
max-width: calc(33.33% - 0.5rem);
|
||||
min-width: calc(33.33% - 0.5rem);
|
||||
}
|
||||
}
|
||||
.gallery-image {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
padding: 0;
|
||||
|
||||
height: auto;
|
||||
max-width: calc(33.33% - 0.5rem);
|
||||
max-width: calc(20% - 0.5rem);
|
||||
min-width: calc(20% - 0.5rem);
|
||||
|
||||
background-color: $bg;
|
||||
border-radius: calc($rad - 0.5rem);
|
||||
|
@ -91,6 +92,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.gallery-item {
|
||||
max-width: calc(25% - 0.5rem);
|
||||
min-width: calc(25% - 0.5rem);
|
||||
}
|
||||
}
|
||||
@media (max-width: 550px) {
|
||||
.gallery-item {
|
||||
max-width: calc(33.33% - 0.5rem);
|
||||
min-width: calc(33.33% - 0.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
.gallery-image {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
246
image.php
246
image.php
|
@ -1,3 +1,5 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
|
@ -5,162 +7,150 @@
|
|||
<?php require_once __DIR__."/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<?php
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| 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....
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Image;
|
||||
use App\Diff;
|
||||
use App\Account;
|
||||
use App\Image;
|
||||
use App\Diff;
|
||||
|
||||
$image_info = new Image;
|
||||
$user_info = new Account;
|
||||
$diff = new Diff();
|
||||
$image_info = new Image;
|
||||
$user_info = new Account;
|
||||
$diff = new Diff();
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| 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 ^^
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
// Get all image info
|
||||
$image = $image_info->get_image_info($conn, $_GET['id']);
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| 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 ^^
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
// Get all image info
|
||||
$image = $image_info->get_image_info($conn, $_GET['id']);
|
||||
|
||||
// Check if image is avalible
|
||||
if (isset($image['imagename'])) {
|
||||
$image_present = True;
|
||||
// Check if image is avalible
|
||||
if (isset($image['imagename'])) {
|
||||
$image_present = True;
|
||||
} else {
|
||||
?>
|
||||
<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)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
$image_present = False;
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
?>
|
||||
<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)', 'assets/icons/cross.svg');
|
||||
sniffleAdd('Where is da image?', 'The link you followed seems to be broken, or there was some other error, who knows!', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
$image_present = False;
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Where is da image?', 'The link you followed seems to be broken, or there was some other error, who knows!', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
$image_present = False;
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Image verification
|
||||
|-------------------------------------------------------------
|
||||
| Doublechecking if all information on images exists, if yes
|
||||
| display it, otherwise don't display at all or replace with
|
||||
| blank or filler info
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_present) {
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user details
|
||||
|-------------------------------------------------------------
|
||||
|-------------------------------------------------------------
|
||||
| Image verification
|
||||
|-------------------------------------------------------------
|
||||
| Doublechecking if all information on images exists, if yes
|
||||
| display it, otherwise don't display at all or replace with
|
||||
| blank or filler info
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($image['author'])) {
|
||||
// Get all information on the user
|
||||
$user = $user_info->get_user_info($conn, $image['author']);
|
||||
if ($image_present) {
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user details
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($image['author'])) {
|
||||
// Get all information on the user
|
||||
$user = $user_info->get_user_info($conn, $image['author']);
|
||||
|
||||
if (isset($user['username'])) {
|
||||
$image_author = $user['username'];
|
||||
if (isset($user['username'])) {
|
||||
$image_author = $user['username'];
|
||||
} else {
|
||||
$image_author = "Deleted User";
|
||||
}
|
||||
} else {
|
||||
$image_author = "Deleted User";
|
||||
$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_author = "No author";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check if image path is good
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($image['imagename'])) {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_alt = $image['alt'];
|
||||
} else {
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Image was not present
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| If description not set or empty, replace with filler
|
||||
|-------------------------------------------------------------
|
||||
|-------------------------------------------------------------
|
||||
| Check user privilge
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (!isset($image_alt) || empty($image_alt)) {
|
||||
$image_alt = "No description avalible";
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
$privilaged = True;
|
||||
} else {
|
||||
$privilaged = False;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (is_file("images/previews/".$image['imagename'])) {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='showFull()'><img src='assets/icons/scan.svg'></button>
|
||||
</div>";
|
||||
?>
|
||||
<script>
|
||||
function showFull() {
|
||||
document.querySelector(".image").style.opacity = 0;
|
||||
document.querySelector(".preview-button").style.display = "none";
|
||||
setTimeout(function(){
|
||||
document.querySelector(".image").src = "<?php echo $image_path;?>";
|
||||
document.querySelector(".image").style.opacity = 1;
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>
|
||||
</div>";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Image was not present
|
||||
|-------------------------------------------------------------
|
||||
|-------------------------------------------------------------
|
||||
| Start of displaying all info on image
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user privilge
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
$privilaged = True;
|
||||
} else {
|
||||
$privilaged = False;
|
||||
}
|
||||
|
||||
if (is_file("images/previews/".$image['imagename'])) {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='showFull()'><img src='assets/icons/scan.svg'></button>
|
||||
</div>";
|
||||
?>
|
||||
<script>
|
||||
function showFull() {
|
||||
document.querySelector(".image").style.opacity = 0;
|
||||
document.querySelector(".preview-button").style.display = "none";
|
||||
setTimeout(function(){
|
||||
document.querySelector(".image").src = "<?php echo $image_path;?>";
|
||||
document.querySelector(".image").style.opacity = 1;
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>
|
||||
</div>";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Start of displaying all info on image
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_present) {
|
||||
if ($image_present) {
|
||||
?>
|
||||
|
||||
<div class="image-description default-window">
|
||||
|
|
23
index.php
23
index.php
|
@ -1,3 +1,5 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
|
@ -6,18 +8,17 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
<?php
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
|
||||
if ($_GET['del']) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "assets/icons/trash.svg");
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
if ($_GET['del']) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "assets/icons/trash.svg");
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="info-text">
|
||||
<?php
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
|
@ -5,21 +7,19 @@
|
|||
<?php require_once __DIR__."/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Account;
|
||||
|
||||
$user_info = new Account();
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if ($user_info->is_loggedin() != true) {
|
||||
header("location: account.php");
|
||||
exit;
|
||||
}
|
||||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if ($user_info->is_loggedin() != true) {
|
||||
header("location: account.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="password-reset-root">
|
||||
|
|
117
ui/nav.php
117
ui/nav.php
|
@ -1,28 +1,105 @@
|
|||
<?php
|
||||
|
||||
use App\Account;
|
||||
|
||||
$loggedin = new Account();
|
||||
?>
|
||||
|
||||
<nav class="nav-root flex-left">
|
||||
<div class="nav-name flex-left">
|
||||
<p><?php echo $user_settings['website_name']; ?></p>
|
||||
</div>
|
||||
<div class="nav-links flex-left">
|
||||
<a class='btn' href='index.php'><img class='svg' src='assets/icons/house.svg'><span class='nav-hide'>Home</span></a>
|
||||
<hr>
|
||||
<?php
|
||||
if ($loggedin->is_loggedin()) {
|
||||
?>
|
||||
<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>
|
||||
<hr>
|
||||
<a class='btn' href='account.php'><img class='svg' src='assets/icons/gear.svg'><span class='nav-hide'><?php echo substr($_SESSION["username"], 0, 15); ?></span></a>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="nav-name flex-left">
|
||||
<p><?php echo $user_settings['website_name']; ?></p>
|
||||
</div>
|
||||
<div class="nav-links flex-left">
|
||||
<a class='btn' href='index.php'><img class='svg' src='assets/icons/house.svg'><span class='nav-hide'>Home</span></a>
|
||||
<hr>
|
||||
<?php
|
||||
if ($loggedin->is_loggedin()) {
|
||||
?>
|
||||
<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>
|
||||
<hr>
|
||||
<a class='btn' href='account.php'><img class='svg' src='assets/icons/gear.svg'><span class='nav-hide'><?php echo substr($_SESSION["username"], 0, 15); ?></span></a>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<script>
|
||||
console.log(". . /|/| . . . . . . .\n\
|
||||
.. /0 0 \\ . . . . . ..\n\
|
||||
(III% . \\________, . .\n\
|
||||
.. .\\_, .%###%/ \\'\\,..\n\
|
||||
. . . .||#####| |'\\ \\.\n\
|
||||
.. . . ||. . .|/. .\\V.\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . .|| . . || . . .\n\
|
||||
.. . . ||. . .||. . ..\n\
|
||||
. . . cc/ . .cc/ . . .");
|
||||
</script>
|
||||
<!--
|
||||
Used by Sniffle to add Notifications
|
||||
Div can be displayed all time as it has no width or height initself
|
||||
-->
|
||||
<div id='sniffle' class='sniffle'></div>
|
||||
|
||||
<!--
|
||||
Div for information flyouts
|
||||
Controlled by Flyout.js
|
||||
-->
|
||||
<div id='flyoutDim' class='flyout-dim'></div>
|
||||
<div id='flyoutRoot' class='flyout'>
|
||||
<p id='flyoutHeader' class='flyout-header'>Header</p>
|
||||
<br>
|
||||
<p id='flyoutDescription' class='flyout-description'>Description</p>
|
||||
<br>
|
||||
<div id='flyoutActionbox' class='flyout-actionbox'></div>
|
||||
<button onclick='flyoutClose()' class='btn btn-neutral'>Close</button>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Back to top button
|
||||
Used to quickly get back up to the top of the page,
|
||||
At some point will be removed as the UI metures and
|
||||
everything can always be accessed
|
||||
-->
|
||||
<a id="back-to-top" href="#">
|
||||
<img src="assets/icons/caret-up.svg">
|
||||
</a>
|
||||
<script>
|
||||
button = document.getElementById("back-to-top");
|
||||
|
||||
window.onscroll = function() {
|
||||
scrollFunction()
|
||||
};
|
||||
|
||||
function scrollFunction() {
|
||||
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
||||
button.style.right = "1rem";
|
||||
} else {
|
||||
button.style.right = "-2.5rem";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
Required so main objects are centered when NAV
|
||||
is in mobile view
|
||||
-->
|
||||
<div class="nav-mobile"></div>
|
|
@ -1,56 +1,6 @@
|
|||
<!--
|
||||
Used by Sniffle to add Notifications
|
||||
Div can be displayed all time as it has no width or height initself
|
||||
-->
|
||||
<div id='sniffle' class='sniffle'></div>
|
||||
|
||||
<!--
|
||||
Div for information flyouts
|
||||
Controlled by Flyout.js
|
||||
-->
|
||||
<div id='flyoutDim' class='flyout-dim'></div>
|
||||
<div id='flyoutRoot' class='flyout'>
|
||||
<p id='flyoutHeader' class='flyout-header'>Header</p>
|
||||
<br>
|
||||
<p id='flyoutDescription' class='flyout-description'>Description</p>
|
||||
<br>
|
||||
<div id='flyoutActionbox' class='flyout-actionbox'></div>
|
||||
<button onclick='flyoutClose()' class='btn btn-neutral'>Close</button>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Back to top button
|
||||
Used to quickly get back up to the top of the page,
|
||||
At some point will be removed as the UI metures and
|
||||
everything can always be accessed
|
||||
-->
|
||||
<a id="back-to-top" href="#">
|
||||
<img src="assets/icons/caret-up.svg">
|
||||
</a>
|
||||
<script>
|
||||
button = document.getElementById("back-to-top");
|
||||
|
||||
window.onscroll = function() {scrollFunction()};
|
||||
|
||||
function scrollFunction() {
|
||||
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
||||
button.style.right = "1rem";
|
||||
} else {
|
||||
button.style.right = "-2.5rem";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
Required so main objects are centered when NAV
|
||||
is in mobile view
|
||||
-->
|
||||
<div class="nav-mobile"></div>
|
||||
|
||||
<?php
|
||||
/*
|
||||
User defined settings
|
||||
*/
|
||||
require_once dirname(__DIR__)."/app/server/conn.php";
|
||||
require_once dirname(__DIR__)."/app/app.php";
|
||||
require_once dirname(__DIR__)."/app/settings/settings.php";
|
||||
|
||||
ini_set('post_max_size', $user_settings['upload_max']."M");
|
||||
|
@ -60,22 +10,4 @@ if ($user_settings['is_testing'] == "true") {
|
|||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Notice', 'This website is currently in a testing state', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/*
|
||||
Connect to the server
|
||||
*/
|
||||
require_once dirname(__DIR__)."/app/server/conn.php";
|
||||
require_once dirname(__DIR__)."/app/server/secrete.php";
|
||||
|
||||
/*
|
||||
Classes
|
||||
*/
|
||||
require_once dirname(__DIR__)."/app/app.php";
|
||||
|
||||
?>
|
||||
}
|
118
upload.php
118
upload.php
|
@ -1,74 +1,27 @@
|
|||
<?php require_once __DIR__."/ui/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/ui/header.php"; ?>
|
||||
|
||||
<!-- Upload Script -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#uploadSubmit").submit(function(event) {
|
||||
event.preventDefault();
|
||||
// Check if image avalible
|
||||
var file = $("#image").val();
|
||||
if (file != "") {
|
||||
// Make form
|
||||
var formData = new FormData();
|
||||
|
||||
// Get image
|
||||
var image_data = $("#image").prop("files")[0];
|
||||
formData.append("image", image_data);
|
||||
// Get ALT
|
||||
var alt = $("#alt").val();
|
||||
formData.append("alt", alt);
|
||||
// Get TAGS
|
||||
var tags = $("#tags").val();
|
||||
formData.append("tags", tags);
|
||||
// Submit data
|
||||
var submit = $("#submit").val();
|
||||
formData.append("submit", submit);
|
||||
|
||||
// Upload the information
|
||||
$.ajax({
|
||||
url: 'app/image/upload_image.php',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$("#sniffle").html(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Empty values
|
||||
$("#image").val("");
|
||||
$("#alt").val("");
|
||||
$("#tags").val("");
|
||||
$("#submit").val("");
|
||||
} else {
|
||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--red)', 'assets/icons/file-search.svg');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/ui/required.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
require_once __DIR__."/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
$user_info = new Account();
|
||||
use App\Account;
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if user is logged in
|
||||
if (!$user_info->is_loggedin()) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
// Check if user is logged in
|
||||
if (!$user_info->is_loggedin()) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="upload-root">
|
||||
|
@ -84,6 +37,51 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#uploadSubmit").submit(function(event) {
|
||||
event.preventDefault();
|
||||
// Check if image avalible
|
||||
var file = $("#image").val();
|
||||
if (file != "") {
|
||||
// Make form
|
||||
var formData = new FormData();
|
||||
|
||||
// Get image
|
||||
var image_data = $("#image").prop("files")[0];
|
||||
formData.append("image", image_data);
|
||||
// Get ALT
|
||||
var alt = $("#alt").val();
|
||||
formData.append("alt", alt);
|
||||
// Get TAGS
|
||||
var tags = $("#tags").val();
|
||||
formData.append("tags", tags);
|
||||
// Submit data
|
||||
var submit = $("#submit").val();
|
||||
formData.append("submit", submit);
|
||||
|
||||
// Upload the information
|
||||
$.ajax({
|
||||
url: 'app/image/upload_image.php',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$("#sniffle").html(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Empty values
|
||||
$("#image").val("");
|
||||
$("#alt").val("");
|
||||
$("#tags").val("");
|
||||
$("#submit").val("");
|
||||
} else {
|
||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--red)', 'assets/icons/file-search.svg');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__."/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue