From 89bab971f37057f594fcbec28f15fc6277fe3e81 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Sat, 24 Sep 2022 16:47:34 +0000 Subject: [PATCH] Progress on fixing shitty groups code? --- app/app.php | 22 +++++---- app/image/group.php | 23 ++++++++++ assets/ui/nav.php | 20 ++++---- css/main.css | 93 +++++++++++++++++++++++++------------ css/scss/_body.scss | 109 ++++++++++++++++++++++++++++++++++++-------- group.php | 63 +++++++++++++++++++------ index.php | 42 +---------------- upload.php | 2 +- 8 files changed, 252 insertions(+), 122 deletions(-) diff --git a/app/app.php b/app/app.php index 7588f35..5593104 100644 --- a/app/app.php +++ b/app/app.php @@ -1,6 +1,8 @@ is_loggedin()) { + $group_name = $_SESSION['username']." new image group"; + $sql = "INSERT INTO groups (group_name, author, image_list) VALUES('$group_name', '".$_SESSION['id']."', '')"; + + mysqli_query($conn, $sql); + + $group_id = mysqli_insert_id($conn); + + ?> + + + + Home
+ Groups +
is_loggedin()) { - ?> - Upload -
- Groups -
- - + Upload +
+ + - Login - + Login + diff --git a/css/main.css b/css/main.css index def1b16..cf08f9a 100644 --- a/css/main.css +++ b/css/main.css @@ -527,6 +527,71 @@ nav .btn { opacity: 1; } +.group-make { + margin: 0.25rem; + padding: 0; + height: auto; + max-width: calc(20% - 0.5rem); + min-width: calc(20% - 0.5rem); + border-radius: -0.1rem; + position: relative; + overflow: hidden; + flex: 1 0 150px; + transition: outline 0.1s cubic-bezier(0.19, 1, 0.22, 1); +} +.group-make:hover { + outline: #E8E3E3 0.2rem solid; +} +.group-make:after { + content: ""; + display: block; + padding-bottom: 100%; +} +.group-make button { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; + padding: 0; + background-color: #121212; + border-radius: -0.1rem; + border: none; + top: 0; + bottom: 0; + left: 0; + right: 0; + position: absolute; + z-index: 5; + text-decoration: none; + font-family: "Secular One", sans-serif; +} +.group-make button:hover { + color: #E8E3E3; + cursor: pointer; +} +.group-make button span { + text-align: center; +} +.group-make button img { + margin: 0.25rem; + width: 2.5rem; + height: 2.5rem; +} + +@media (max-width: 800px) { + .group-make { + max-width: calc(25% - 0.5rem); + min-width: calc(25% - 0.5rem); + } +} +@media (max-width: 550px) { + .group-make { + max-width: calc(33.33% - 0.5rem); + min-width: calc(33.33% - 0.5rem); + } +} /* |------------------------------------------------------------- | profile @@ -814,34 +879,6 @@ nav .btn { top: 0; } -/* - |------------------------------------------------------------- - | PASSWORD RESET - |------------------------------------------------------------- -*/ -.password-reset-root { - background-color: #151515; - color: #E8E3E3; - border-radius: 0.4rem; - border: 0.2rem solid #B66467; - box-shadow: 6px 6px 2px rgba(21, 21, 21, 0.4); -} -.password-reset-root h1, -.password-reset-root h2, -.password-reset-root h3, -.password-reset-root h4, -.password-reset-root h5 { - font-family: "Lexend Deca", sans-serif; - text-rendering: optimizeLegibility; -} -.password-reset-root p, -.password-reset-root a, -.password-reset-root button, -.password-reset-root input { - font-family: "Secular One", sans-serif; - text-rendering: optimizeLegibility; -} - /* |------------------------------------------------------------- | FOOTER diff --git a/css/scss/_body.scss b/css/scss/_body.scss index a4c4448..4eae7fb 100644 --- a/css/scss/_body.scss +++ b/css/scss/_body.scss @@ -431,6 +431,89 @@ } } } + +.group-make { + margin: 0.25rem; + padding: 0; + + height: auto; + max-width: calc(20% - 0.5rem); + min-width: calc(20% - 0.5rem); + + border-radius: calc($rad - 0.5rem); + + position: relative; + + overflow: hidden; + + flex: 1 0 150px; + + transition: outline 0.1s cubic-bezier(.19, 1, .22, 1); + + &:hover { + outline: $white 0.2rem solid; + } + + &:after { + content: ""; + display: block; + padding-bottom: 100%; + } + + button { + @include flexDown(center); + align-items: center; + + width: 100%; + height: 100%; + + padding: 0; + + background-color: $black; + border-radius: calc($rad - 0.5rem); + border: none; + + top: 0; + bottom: 0; + left: 0; + right: 0; + + position: absolute; + z-index: 5; + + text-decoration: none; + font-family: $font-body; + + &:hover { + color: $fg; + + cursor: pointer; + } + + span { + text-align: center; + } + + img { + margin: 0.25rem; + + width: 2.5rem; + height: 2.5rem; + } + } +} +@media (max-width: 800px) { + .group-make { + max-width: calc(25% - 0.5rem); + min-width: calc(25% - 0.5rem); + } +} +@media (max-width: 550px) { + .group-make { + max-width: calc(33.33% - 0.5rem); + min-width: calc(33.33% - 0.5rem); + } +} /* |------------------------------------------------------------- | profile @@ -509,18 +592,16 @@ | UPLOAD |------------------------------------------------------------- */ -.upload-root { - & > img { - margin: 0 auto; +.upload-root > img { + margin: 0 auto; - max-width: 100%; - max-height: 15rem; + max-width: 100%; + max-height: 15rem; - border-radius: calc($rad - 0.7rem); + border-radius: calc($rad - 0.7rem); - display: flex; - flex-direction: column; - } + display: flex; + flex-direction: column; } /* @@ -750,14 +831,4 @@ background-color: $bg; position: sticky; top: 0; -} - -/* - |------------------------------------------------------------- - | PASSWORD RESET - |------------------------------------------------------------- -*/ -.password-reset-root { - @include defaultDecoration($red); - @include defaultFont(); } \ No newline at end of file diff --git a/group.php b/group.php index 5e6b833..1e8137c 100644 --- a/group.php +++ b/group.php @@ -10,6 +10,12 @@ $image_info = new Image; $group_info = new Group; $diff = new Diff(); + + if (isset($_GET['id'])) { + $group = $group_info->get_group_info($conn, $_GET['id']); + + if (!isset($group) || empty($group)) header("Location: group.php"); + } ?> @@ -22,8 +28,6 @@ get_group_info($conn, $_GET['id']); - if (!isset($group) || empty($group)) header("Location: group.php"); $image_list = array_reverse(explode(" ", $group['image_list'])); echo "
"; @@ -34,12 +38,14 @@ echo "

By: ".$author_info['username']."

"; $group_members = $group_info->get_group_members($conn, $_GET['id']); - $members_array = array(); - foreach ($group_members as $member) { - $member_info = $user_info->get_user_info($conn, $member); - array_push($members_array, $member_info['username']); + if (!empty($group_members)) { + $members_array = array(); + foreach ($group_members as $member) { + $member_info = $user_info->get_user_info($conn, $member); + if (!empty($member_info['username'])) $members_array[] = $member_info['username']; + } + echo "

Members: ".implode(", ", $members_array)."

"; } - echo "

Members: ".implode(", ", $members_array)."

"; $upload_time = new DateTime($group['created_on']); echo "

Created at: ".$upload_time->format('d/m/Y H:i:s T').""; @@ -167,11 +173,15 @@ var groupSubmit = $("#groupSubmit").val(); var images = getList(); - $("#sniffle").load("app/image/group.php", { - group_images: images, - group_id: , - group_submit: groupSubmit - }); + if (images <= 0) { + sniffleAdd('Oppsie', 'Groups need at least 1 image in them. Alternativly, you can delete this group.', 'var(--red)', 'assets/icons/cross.svg'); + } else { + $("#sniffle").load("app/image/group.php", { + group_images: images, + group_id: , + group_submit: groupSubmit + }); + } }); is_loggedin()) { + echo "

+ +
"; + + ?> + + get_image_info($conn, $image_list[array_rand($image_list, 1)]); // Getting thumbnail - if (file_exists("images/thumbnails/".$image['imagename'])) { - $image_path = "images/thumbnails/".$image['imagename']; + if (!empty($image['imagename'])) { + if (file_exists("images/thumbnails/".$image['imagename'])) { + $image_path = "images/thumbnails/".$image['imagename']; + } else { + $image_path = "images/".$image['imagename']; + } } else { - $image_path = "images/".$image['imagename']; + $image_path = "assets/no_image.png"; } + // Check for NSFW tag if (str_contains($image['tags'], "nsfw")) { diff --git a/index.php b/index.php index 489b93f..ede8214 100644 --- a/index.php +++ b/index.php @@ -1,10 +1,4 @@ - + @@ -54,40 +48,6 @@ ?>
- -