Working on getting new components to work with AJAX and Jquery

This commit is contained in:
Michał Gdula 2022-08-08 12:43:57 +01:00
parent ffa8a8e1a3
commit d8b20c9b34
15 changed files with 344 additions and 123 deletions

View file

@ -1,27 +1,73 @@
<?php
/*
Confirm deleting user
user must be privilaged to do this action this the privilaged == true
|-------------------------------------------------------------
| Delete image
|-------------------------------------------------------------
| This is the scarries code I written. I hate writing anything
| like this, please help
|-------------------------------------------------------------
*/
if (isset($_POST['delete_confirm']) && $privilaged) {
// Unset all the variables, needed by flyout
unset($header, $content, $action);
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'])) {
// 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) {
// Delete from table
$image_delete_request = "DELETE FROM swag_table WHERE id =".$image['id'];
$image_delete = mysqli_query($conn,$image_delete_request);
$sql = "DELETE FROM swag_table WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "i", $param_id);
if ($image_delete) {
// Setting parameters
$param_id = $_POST['id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
// See if image is in the directory
if (is_file("images/".$image['imagename'])) {
unlink("images/".$image['imagename']);
if (is_file("../../images/".$image_array['imagename'])) {
unlink("../../images/".$image_array['imagename']);
}
// Delete thumbnail if exitsts
if (is_file("images/thumbnails/".$image['imagename'])) {
unlink("images/thumbnails/".$image['imagename']);
if (is_file("../../images/thumbnails/".$image_array['imagename'])) {
unlink("../../images/thumbnails/".$image_array['imagename']);
}
header("Location:index.php?del=true&id=".$image['id']);
// TP user to the homepage with a success message
?>
<script>
window.location.replace("index.php?del=true&id=<?php echo $_POST['id']; ?>");
</script>
<?php
} else {
header("Location: image.php?id=".$image['id']."&del=fail>");
?>
<script>
sniffleAdd('Oopsie', 'The image failed to delete off of the servers, contact Fluffy about his terrible programming', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
// nice uwu

View file

@ -1,10 +1,18 @@
<?php
/*
Author confirm
|-------------------------------------------------------------
| Edit Author
|-------------------------------------------------------------
| If this has security problems I'm so fucked
|-------------------------------------------------------------
*/
if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) {
// Unset all the variables, needed by flyout
unset($header, $content, $action);
session_start();
// Include server connection
include "../server/conn.php";
if (isset($_POST['submit'])) {
// If user has the ID of 1
if ($_SESSION['id'] == 1) {
// getting ready forSQL asky asky
$sql = "UPDATE swag_table SET author=? WHERE id=?";
@ -13,14 +21,32 @@ if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) {
mysqli_stmt_bind_param($stmt, "si", $param_author, $param_id);
// Setting parameters
$param_author = $_POST['update_author'];
$param_id = $image["id"];
$param_author = $_POST['input'];
$param_id = $_POST["id"];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
header("Location:image.php?id=".$image["id"]."&update=success");
?>
<script>
sniffleAdd('Success!!!', 'The Author has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
header("Location:image.php?id=".$image["id"]."&update=error");
?>
<script>
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
} else {
?>
<script>
sniffleAdd('Denied', 'Sussy wussy.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}

View file

@ -1,16 +1,30 @@
<?php
$conn_ip = "localhost";
$conn_username = "uwu";
$conn_password = "fennec621";
$conn_database = "swag";
$conn = mysqli_connect($conn_ip, $conn_username, $conn_password , $conn_database);
if ($conn->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'])) {
// 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=?";
@ -19,14 +33,39 @@ if (isset($_POST['submit'])) {
mysqli_stmt_bind_param($stmt, "si", $param_alt, $param_id);
// Setting parameters
$param_alt = $_POST['description'];
$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')";
?>
<script>
sniffleAdd('Success!!!', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
echo "sniffleAdd('Error', 'An error occured on the servers', 'var(--red)', ".$root_dir."'assets/icons/check.svg')";
}
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}

View file

@ -5,20 +5,46 @@ if (isset($_POST['tags_confirm']) && $privilaged) {
// Unset all the variables, needed by flyout
unset($header, $content, $action);
// Clean tags before adding
function clean($string) {
// Change to lowercase
$string = strtolower($string);
// Replace hyphens
$string = str_replace('-', '_', $string);
// Regex
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
// Return string
return preg_replace('/ +/', ' ', $string);
}
header("Location:image.php?id=".$image["id"]."&update=success");
} else {
header("Location:image.php?id=".$image["id"]."&update=error");
}
}
}
<?php
/*
|-------------------------------------------------------------
| 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";
// Tag cleaning
include "../format/string_to_tags.php";
if (isset($_POST['submit'])) {
// 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) {
// Clean input
$tags_string = tag_clean(trim($_POST['add_tags']));
$tags_string = tag_clean(trim($_POST['input']));
// getting ready forSQL asky asky
$sql = "UPDATE swag_table SET tags=? WHERE id=?";
@ -29,13 +55,38 @@ if (isset($_POST['tags_confirm']) && $privilaged) {
// Setting parameters
$param_tags = $tags_string;
$param_id = $image["id"];
$param_id = $_POST['id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
header("Location:image.php?id=".$image["id"]."&update=success");
?>
<script>
sniffleAdd('Success!!!', 'Tags have been modified successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
header("Location:image.php?id=".$image["id"]."&update=error");
}
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to modify tags here.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><polyline points="172 104 113.3 160 84 132" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></polyline></svg>

After

Width:  |  Height:  |  Size: 730 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><circle cx="128" cy="180" r="12"></circle><path d="M128,144v-8a28,28,0,1,0-28-28" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>

After

Width:  |  Height:  |  Size: 764 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#cccccc" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#cccccc" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M54.5,201.5c-9.2-9.2-3.1-28.5-7.8-39.8S24,140.5,24,128s17.8-22,22.7-33.7-1.4-30.6,7.8-39.8S83,51.4,94.3,46.7,115.5,24,128,24s22,17.8,33.7,22.7,30.6-1.4,39.8,7.8,3.1,28.5,7.8,39.8S232,115.5,232,128s-17.8,22-22.7,33.7,1.4,30.6-7.8,39.8-28.5,3.1-39.8,7.8S140.5,232,128,232s-22-17.8-33.7-22.7S63.7,210.7,54.5,201.5Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 581 B

Before After
Before After

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><line x1="96" y1="152" x2="160" y2="152" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line><line x1="96" y1="120" x2="160" y2="120" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line><path d="M160,40h40a8,8,0,0,1,8,8V216a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H96" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><path d="M88,72V64a40,40,0,0,1,80,0v8Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>

After

Width:  |  Height:  |  Size: 774 B

1
assets/icons/cookie.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M224,127.4a95.6,95.6,0,0,1-28.2,68.5c-36.9,36.9-97.3,37.3-134.7.9A96,96,0,0,1,128.6,32a8.1,8.1,0,0,1,7.8,9.8,32,32,0,0,0,30.8,39,8,8,0,0,1,8,8,32,32,0,0,0,39,30.8A8.1,8.1,0,0,1,224,127.4Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><circle cx="156" cy="172" r="12"></circle><circle cx="92" cy="164" r="12"></circle><circle cx="84" cy="108" r="12"></circle><circle cx="136" cy="124" r="12"></circle></svg>

After

Width:  |  Height:  |  Size: 623 B

1
assets/icons/export.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><polyline points="86 58 128 16 170 58" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></polyline><line x1="128" y1="128" x2="128" y2="16" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line><path d="M176,96h24a8,8,0,0,1,8,8V208a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V104a8,8,0,0,1,8-8H80" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>

After

Width:  |  Height:  |  Size: 636 B

1
assets/icons/gear.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><circle cx="128" cy="128" r="48" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></circle><path d="M183.7,65.1q3.8,3.5,7.2,7.2l27.3,3.9a103.2,103.2,0,0,1,10.2,24.6l-16.6,22.1s.3,6.8,0,10.2l16.6,22.1a102.2,102.2,0,0,1-10.2,24.6l-27.3,3.9s-4.7,4.9-7.2,7.2l-3.9,27.3a103.2,103.2,0,0,1-24.6,10.2l-22.1-16.6a57.9,57.9,0,0,1-10.2,0l-22.1,16.6a102.2,102.2,0,0,1-24.6-10.2l-3.9-27.3q-3.7-3.5-7.2-7.2l-27.3-3.9a103.2,103.2,0,0,1-10.2-24.6l16.6-22.1s-.3-6.8,0-10.2L27.6,100.8A102.2,102.2,0,0,1,37.8,76.2l27.3-3.9q3.5-3.7,7.2-7.2l3.9-27.3a103.2,103.2,0,0,1,24.6-10.2l22.1,16.6a57.9,57.9,0,0,1,10.2,0l22.1-16.6a102.2,102.2,0,0,1,24.6,10.2Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path></svg>

After

Width:  |  Height:  |  Size: 934 B

1
assets/icons/tag.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M122.7,25.9,42,42,25.9,122.7a8,8,0,0,0,2.2,7.2L132.5,234.3a7.9,7.9,0,0,0,11.3,0l90.5-90.5a7.9,7.9,0,0,0,0-11.3L129.9,28.1A8,8,0,0,0,122.7,25.9Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><circle cx="84" cy="84" r="12"></circle></svg>

After

Width:  |  Height:  |  Size: 453 B

View file

@ -256,9 +256,7 @@ body {
border-radius: var(--rad);
}
.tag::before {
content: '#';
}
/*
-=-=-= UNIVERSAL =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/

122
image.php
View file

@ -98,16 +98,8 @@
$privilaged = False;
}
include"ui/nav.php"; ?>
<script>
if (params.update == "success") {
sniffleAdd("Info", "Image information updated", "var(--green)");
}
if (params.del == "fail") {
sniffleAdd("Error", "Failed to delete image", "var(--red)");
}
</script>
include "ui/nav.php";
?>
<div class="image-container space-bottom-large">
<img class='image' id='<?php echo $image['id']; ?>' src='<?php echo $image_path; ?>' alt='<?php echo $image_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 "<p class='tag alert-high'>".$tag."</p>";
echo "<p class='tag alert-high'><img class='svg' src='assets/icons/tag.svg'>".$tag."</p>";
}
} else {
echo "<p>No tags present</p>";
@ -200,24 +192,42 @@
<script id="conformationMessage"></script>
<!-- Delete -->
<!--
|-------------------------------------------------------------
| Delete
|-------------------------------------------------------------
| sus
| I cannot describe the anxiety this gives me. pls help
|-------------------------------------------------------------
-->
<button id='deleteButton' class='btn alert-low'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>
<script>
$('#deleteButton').click(function() {
var header = "Are you sure?";
var description = "Deleting this image is pernament, there is no going back after this!!!!!";
var actionBox = "<button class='btn alert-low'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>";
var actionBox = "<form id='deleteConfirm' method='POST'>\
<button id='deleteSubmit' class='btn alert-low' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>\
</form>";
flyoutShow(header, description, actionBox);
$("#deleteConfirm").submit(function(event) {
event.preventDefault();
var deleteSubmit = $("#deleteSubmit").val();
$("#conformationMessage").load("app/image/delete_image.php", {
id: <?php echo $_GET['id']; ?>,
submit: deleteSubmit
});
});
});
</script>
<!--
|-------------------------------------------------------------
| Edit description
| Edit Description
|-------------------------------------------------------------
| Most people reading through the code will probably say
| how shit it is. YOU HAVE NO FUCKING CLUE HOW LONG THIS TOOK
| ME TO FIGURE OUT. i hate js.
| Most people reading through the code will probably say how
| shit it is. YOU HAVE NO FUCKING CLUE HOW LONG THIS TOOK ME
| TO FIGURE OUT. i hate js.
|-------------------------------------------------------------
-->
<button id='descriptionButton' class='btn alert-low space-top-small'><img class='svg' src='assets/icons/edit.svg'>Edit description</button>
@ -226,8 +236,8 @@
var header = "Enter new Description/Alt";
var description = "Whatcha gonna put in there 👀";
var actionBox = "<form id='descriptionConfirm' action='app/image/edit_description.php' method='POST'>\
<input id='descriptionInput' class='btn alert-default space-bottom' type='text' name='descriptionInput' placeholder='Description/Alt for image'>\
<button id='descriptionSubmit' class='btn alert-low' type='submit' name='descriptionSubmit'><img class='svg' src='assets/icons/edit.svg'>Update information</button>\
<input id='descriptionInput' class='btn alert-default space-bottom' type='text' placeholder='Description/Alt for image'>\
<button id='descriptionSubmit' class='btn alert-low' type='submit'><img class='svg' src='assets/icons/edit.svg'>Update information</button>\
</form>";
flyoutShow(header, description, actionBox);
@ -235,38 +245,82 @@
event.preventDefault();
var descriptionInput = $("#descriptionInput").val();
var descriptionSubmit = $("#descriptionSubmit").val();
$.post("app/image/edit_description.php", {
$("#conformationMessage").load("app/image/edit_description.php", {
id: <?php echo $_GET['id']; ?>,
description: descriptionInput,
input: descriptionInput,
submit: descriptionSubmit
}, function(returnData) {
$("#conformationMessage").html(returnData);
});
});
});
</script>
<!-- Edit tags -->
<button id='tagButton' class='btn alert-low space-top-small'><img class='svg' src='assets/icons/edit.svg'>Add image tags</button>
<!--
|-------------------------------------------------------------
| Edit Tags
|-------------------------------------------------------------
| Literally no amount of work will get tags/lists to play well
| with SQL so I gave up and made my own shitty system. It
| works but once I re-add the search function this will make
| anyone cry. I am so sorry.
|-------------------------------------------------------------
-->
<button id='tagsButton' class='btn alert-low space-top-small'><img class='svg' src='assets/icons/tag.svg'>Add image tags</button>
<script>
$('#tagButton').click(function(){
$('#tagsButton').click(function() {
var header = "Tags";
var description = "Add image tags here! This is still being tested so your tags may be removed later on. Tags ONLY accept, letters, numbers and underscores. Hyphens will be stitched to underscores and spaces will seperate the different tags from eachother";
var actionBox = "<input class='btn alert-default space-bottom' type='text' name='add_tags' placeholder='Tags are seperated by spaces'>\
<button class='btn alert-low'><img class='svg' src='assets/icons/edit.svg'>Add tags</button>";
var actionBox = "<form id='tagsConfirm' action='app/image/edit_tags.php' method='POST'>\
<input id='tagsInput' class='btn alert-default space-bottom' type='text' placeholder='Tags are seperated by spaces'>\
<button id='tagsSubmit' class='btn alert-low' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit tags</button>\
</form>";
flyoutShow(header, description, actionBox);
$("#tagsConfirm").submit(function(event) {
event.preventDefault();
var tagsInput = $("#tagsInput").val();
var tagsSubmit = $("#tagsSubmit").val();
$("#conformationMessage").load("app/image/edit_tags.php", {
id: <?php echo $_GET['id']; ?>,
input: tagsInput,
submit: tagsSubmit
});
});
});
</script>
<!-- Edit authro -->
<!--
|-------------------------------------------------------------
| Edit Author
|-------------------------------------------------------------
| You must be a super cool person to see this section ;3
|-------------------------------------------------------------
-->
<?php
if (is_admin($_SESSION['id'])) {
?>
<form id='author_form' method='POST' action='ui/image_interaction.php'>
<input id='author_header' type='hidden' name='header' value='Who owns the image?????'>
<input id='author_description' type='hidden' name='description' value='Enter ID of image owner'>
<button id='author_submit' class='btn alert-low space-top-small' type='submit' name='author_flyout'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
</form>
<button id='authorButton' class='btn alert-low space-top-small'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
<script>
$('#authorButton').click(function() {
var header = "Who owns the image?????";
var description = "Enter ID of image owner";
var actionBox = "<form id='authorConfirm' action='app/image/edit_author.php' method='POST'>\
<input id='authorInput' class='btn alert-default space-bottom' type='text' placeholder='le author'>\
<button id='authorSubmit' class='btn alert-low' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>\
</form>";
flyoutShow(header, description, actionBox);
$("#authorConfirm").submit(function(event) {
event.preventDefault();
var authorInput = $("#authorInput").val();
var authorSubmit = $("#authorSubmit").val();
$("#conformationMessage").load("app/image/edit_author.php", {
id: <?php echo $_GET['id']; ?>,
input: authorInput,
submit: authorSubmit
});
});
});
</script>
<?php
}
echo "</div>";

View file

@ -33,7 +33,7 @@
?>
<script>
sniffleAdd("Warning", "The website is currently being worked on, people who have accounts, I ask you kindly to not post anything. Thank you.", "var(--red)", "<?php echo $root_dir ?>assets/icons/warning.svg");
sniffleAdd("Warning", "The website is currently being worked on, some functionality has been restored, but tread carefully as errors may occur", "var(--red)", "<?php echo $root_dir ?>assets/icons/warning.svg");
if (params.del == "true") {
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "<?php echo $root_dir ?>assets/icons/trash.svg");