diff --git a/image.php b/image.php index 81534b6..6cc21af 100644 --- a/image.php +++ b/image.php @@ -1,3 +1,55 @@ +Could not find image with ID: ".$_GET['id']."

"; + + // 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 "

No ID present

"; + + // 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); +} +?> + @@ -8,11 +60,12 @@ + "; ?> + "; ?> Information updated

"; - } elseif ($_GET["update"] == "skip") { - echo "

No alt, skip

"; - } - - - // 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 "

Could not find image with ID: ".$_GET['id']."

"; - - // 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 "

No ID present

"; - - // 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); + } elseif ($_GET["update"] == "error") { + echo "

Something went fuckywucky, please try later

"; } @@ -80,6 +96,17 @@ } + /* + Test flyout button + */ + if (isset($_POST['test_flyout'])) { + $header = "Sus"; + $content = "This is a test UwU. You are currently viewing image: ".$_GET['id']; + $action = "This button does nothing! I'm another button, but scawwy"; + + flyout($header, $content, $action); + } + /* Delete flyout @@ -122,17 +149,85 @@ } } - /* - Test flyout button + Description edit */ - if (isset($_POST['test_flyout'])) { - $header = "Sus"; - $content = "This is a test UwU. You are currently viewing image: ".$_GET['id']; - $action = "This button does nothing! I'm another button, but scawwy"; + if (isset($_POST['description_flyout']) && $privilaged) { + $header = "Enter new Description/Alt"; + $content = "Whatcha gonna put in there 👀"; + $action = "
+ + +
"; flyout($header, $content, $action); } + /* + Description confirm + */ + if (isset($_POST['description_confirm']) && $privilaged) { + // Unset all the variables, needed by flyout + unset($header, $content, $action); + + // getting ready forSQL asky asky + $sql = "UPDATE swag_table SET alt=? WHERE id=?"; + + // Checking if databse is doing ok + if ($stmt = mysqli_prepare($conn, $sql)) { + mysqli_stmt_bind_param($stmt, "si", $param_alt, $param_id); + + // Setting parameters + $param_alt = $_POST['update_alt']; + $param_id = $image["id"]; + + // Attempt to execute the prepared statement + if (mysqli_stmt_execute($stmt)) { + header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$image["id"]."&update=success"); + } else { + header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$image["id"]."&update=error"); + } + } + } + + /* + Description athor + */ + if (isset($_POST['author_flyout']) && $_SESSION['id'] == 1) { + $header = "Who owns the image?????"; + $content = "Enter ID of image owner"; + $action = "
+ + +
"; + + flyout($header, $content, $action); + } + /* + Author confirm + */ + if (isset($_POST['author_confirm']) && $_SESSION['id'] == 1) { + // Unset all the variables, needed by flyout + unset($header, $content, $action); + + // getting ready forSQL asky asky + $sql = "UPDATE swag_table SET author=? WHERE id=?"; + + // Checking if databse is doing ok + if ($stmt = mysqli_prepare($conn, $sql)) { + mysqli_stmt_bind_param($stmt, "si", $param_author, $param_id); + + // Setting parameters + $param_author = $_POST['update_author']; + $param_id = $image["id"]; + + // Attempt to execute the prepared statement + if (mysqli_stmt_execute($stmt)) { + header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$image["id"]."&update=success"); + } else { + header("Location:https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$image["id"]."&update=error"); + } + } + } ?>
@@ -219,13 +314,21 @@ echo "

Danger zone

"; - // Delete Button + // Delete echo "
- + +
"; + + // Edit description + echo "
+ +
"; + + // Edit authro + echo "
+
"; - // Edit image button - echo "Modify image content"; echo "
"; } ?> diff --git a/scripts/flyout.js b/scripts/flyout.js index 2519df4..bc67a99 100644 --- a/scripts/flyout.js +++ b/scripts/flyout.js @@ -1,3 +1,5 @@ +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/ . . .") + let show = document.querySelectorAll(".flyout-display"); let hide = document.querySelector(".flyout-close");