From 5a591c59bc4bf5d755308f55b720485a794d7492 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Wed, 21 Sep 2022 13:02:38 +0000 Subject: [PATCH] Code cleanup in progress --- about.php | 8 +- account.php | 13 +- app/server/secrete.php | 25 ---- app/settings/manifest.json | 2 +- app/settings/settings.php | 10 +- css/main.css | 15 ++- css/scss/_body.scss | 16 ++- image.php | 246 ++++++++++++++++++------------------- index.php | 23 ++-- password-reset.php | 20 +-- ui/nav.php | 117 +++++++++++++++--- ui/required.php | 74 +---------- upload.php | 118 +++++++++--------- 13 files changed, 339 insertions(+), 348 deletions(-) delete mode 100644 app/server/secrete.php diff --git a/about.php b/about.php index 18e1d22..30ce0c0 100644 --- a/about.php +++ b/about.php @@ -1,3 +1,5 @@ + + @@ -5,12 +7,8 @@ - - +

diff --git a/account.php b/account.php index e93b3c7..eef3200 100644 --- a/account.php +++ b/account.php @@ -1,3 +1,5 @@ + + @@ -7,14 +9,13 @@ - 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/ . . ."); - \ No newline at end of file diff --git a/app/settings/manifest.json b/app/settings/manifest.json index dca09b2..931549b 100644 --- a/app/settings/manifest.json +++ b/app/settings/manifest.json @@ -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" diff --git a/app/settings/settings.php b/app/settings/settings.php index 84cf2fa..b315fa7 100644 --- a/app/settings/settings.php +++ b/app/settings/settings.php @@ -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); \ No newline at end of file diff --git a/css/main.css b/css/main.css index aec0d1d..fc5c4e2 100644 --- a/css/main.css +++ b/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; diff --git a/css/scss/_body.scss b/css/scss/_body.scss index 2d03dfd..4825c49 100644 --- a/css/scss/_body.scss +++ b/css/scss/_body.scss @@ -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; diff --git a/image.php b/image.php index 0930052..3f2af79 100644 --- a/image.php +++ b/image.php @@ -1,3 +1,5 @@ + + @@ -5,162 +7,150 @@ - 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 { + ?> + + + ?> - - 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 "
+ ".$image_alt." + +
"; + ?> + + + ".$image_alt." +
"; + } + + /* - |------------------------------------------------------------- - | 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 "
- ".$image_alt." - -
"; - ?> - - - ".$image_alt." - "; - } - - - /* - |------------------------------------------------------------- - | Start of displaying all info on image - |------------------------------------------------------------- - */ - if ($image_present) { + if ($image_present) { ?>
diff --git a/index.php b/index.php index 2cbfd16..85bbd74 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,5 @@ + + @@ -6,18 +8,17 @@ - - - + if ($_GET['del']) { + ?> + +
+ @@ -5,21 +7,19 @@ - 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; + } ?>
diff --git a/ui/nav.php b/ui/nav.php index df84c3d..423aa68 100644 --- a/ui/nav.php +++ b/ui/nav.php @@ -1,28 +1,105 @@ + + + +
+ + +
+
+

Header

+
+

Description

+
+
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/ui/required.php b/ui/required.php index f43c1c8..cba2be3 100644 --- a/ui/required.php +++ b/ui/required.php @@ -1,56 +1,6 @@ - -
- - -
-
-

Header

-
-

Description

-
-
- -
- - - - - - - - - - - - \ No newline at end of file +} \ No newline at end of file diff --git a/upload.php b/upload.php index 41822d9..0278b23 100644 --- a/upload.php +++ b/upload.php @@ -1,74 +1,27 @@ + + - - - is_loggedin()) { - ?> - - is_loggedin()) { + ?> + +
@@ -84,6 +37,51 @@
+ +