From d8b20c9b34fa7ddf06ff860f7854f1f57de1ee0e Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Mon, 8 Aug 2022 12:43:57 +0100 Subject: [PATCH] Working on getting new components to work with AJAX and Jquery --- app/image/delete_image.php | 84 +++++++++++++---- app/image/edit_author.php | 60 ++++++++---- app/image/edit_description.php | 81 ++++++++++++----- app/image/edit_tags.php | 101 ++++++++++++++++----- assets/icons/circle-wavy-check.svg | 1 + assets/icons/circle-wavy-question.svg | 1 + assets/icons/circle-wavy.svg | 2 +- assets/icons/clipboard-text.svg | 1 + assets/icons/cookie.svg | 1 + assets/icons/export.svg | 1 + assets/icons/gear.svg | 1 + assets/icons/tag.svg | 1 + css/master.css | 4 +- image.php | 126 ++++++++++++++++++-------- index.php | 2 +- 15 files changed, 344 insertions(+), 123 deletions(-) create mode 100644 assets/icons/circle-wavy-check.svg create mode 100644 assets/icons/circle-wavy-question.svg create mode 100644 assets/icons/clipboard-text.svg create mode 100644 assets/icons/cookie.svg create mode 100644 assets/icons/export.svg create mode 100644 assets/icons/gear.svg create mode 100644 assets/icons/tag.svg diff --git a/app/image/delete_image.php b/app/image/delete_image.php index 7871696..c15c0cf 100644 --- a/app/image/delete_image.php +++ b/app/image/delete_image.php @@ -1,27 +1,73 @@ + + + + + + + "); + ?> + + + + + + + + connect_error) { - // Send notification that connection couldn't be made -} +/* + |------------------------------------------------------------- + | Edit Description + |------------------------------------------------------------- + | This script took probably over 24hours to write, mostly + | because of my stupidity. But it (mostly) works now which is + | good. Reason for all the includes and session_start is due + | to the need of checking if the person owns the image. If this + | check is not done, someone could come by and just edit the + | Jquery code on the front-end and change the image ID. Which + | isnt too great :p + |------------------------------------------------------------- +*/ +session_start(); +// Include server connection +include "../server/conn.php"; +// Include required checks +include "get_image_info.php"; +include "image_privilage.php"; if (isset($_POST['submit'])) { - // getting ready forSQL asky asky - $sql = "UPDATE swag_table SET alt=? WHERE id=?"; + // Get all image info + $image_array = get_image_info($conn, $_POST['id']); + // If user owns image or has the ID of 1 + if (image_privilage($image_array['author']) || $_SESSION['id'] == 1) { + // 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); + // 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['description']; - $param_id = $_POST['id']; + // Setting parameters + $param_alt = $_POST['input']; + $param_id = $_POST['id']; - // Attempt to execute the prepared statement - if (mysqli_stmt_execute($stmt)) { - echo "sniffleAdd('Info', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', ".$root_dir."'assets/icons/check.svg')"; + // Attempt to execute the prepared statement + if (mysqli_stmt_execute($stmt)) { + ?> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/icons/circle-wavy-question.svg b/assets/icons/circle-wavy-question.svg new file mode 100644 index 0000000..6f43cb5 --- /dev/null +++ b/assets/icons/circle-wavy-question.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/circle-wavy.svg b/assets/icons/circle-wavy.svg index 839e559..0721523 100644 --- a/assets/icons/circle-wavy.svg +++ b/assets/icons/circle-wavy.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/assets/icons/clipboard-text.svg b/assets/icons/clipboard-text.svg new file mode 100644 index 0000000..8c3857e --- /dev/null +++ b/assets/icons/clipboard-text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/cookie.svg b/assets/icons/cookie.svg new file mode 100644 index 0000000..70c21ba --- /dev/null +++ b/assets/icons/cookie.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/export.svg b/assets/icons/export.svg new file mode 100644 index 0000000..5bac907 --- /dev/null +++ b/assets/icons/export.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/gear.svg b/assets/icons/gear.svg new file mode 100644 index 0000000..bbce50d --- /dev/null +++ b/assets/icons/gear.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/tag.svg b/assets/icons/tag.svg new file mode 100644 index 0000000..f4dbfde --- /dev/null +++ b/assets/icons/tag.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/css/master.css b/css/master.css index 54f89ed..cf789b7 100644 --- a/css/master.css +++ b/css/master.css @@ -256,9 +256,7 @@ body { border-radius: var(--rad); } -.tag::before { - content: '#'; -} + /* -=-=-= UNIVERSAL =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */ diff --git a/image.php b/image.php index 45a7da0..4c52852 100644 --- a/image.php +++ b/image.php @@ -98,16 +98,8 @@ $privilaged = False; } - include"ui/nav.php"; ?> - - + include "ui/nav.php"; + ?>
' src='' alt=''> @@ -174,7 +166,7 @@ if (isset($image['tags']) && !empty($image['tags'])) { $image_tags_array = explode(" ", $image['tags']); foreach ($image_tags_array as $tag) { - echo "

".$tag."

"; + echo "

".$tag."

"; } } else { echo "

No tags present

"; @@ -200,34 +192,52 @@ - + - - + + - + -
- - - -
+ + "; diff --git a/index.php b/index.php index 06e8d0f..025ed73 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ ?>