commit 00c944208cb4cedad0eaba85212ca4edf47cab24
parent 055cea436cbff439fd87364a904f8136b1553810
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 26 Oct 2024 12:54:42 +0200
fet: add delete button in list
Diffstat:
5 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/assets/css/custom.css b/assets/css/custom.css
@@ -69,3 +69,12 @@ header {
background-color: #ff6161 !important;
border-color: #ff6161 !important;
}
+
+.danger.likeanchor {
+ background-color: unset !important;
+ border-color: unset !important;
+ color: #ff0000 !important;
+}
+.danger.likeanchor:hover {
+ color: #ff6161 !important;
+}
diff --git a/index.php b/index.php
@@ -76,6 +76,9 @@
if (empty($filename)) {
$filename = generate_filename($content);
}
+ if (empty($category)) {
+ $category = "unknown";
+ }
/* edit note */
edit_note(
$user,
diff --git a/lib/helpers.php b/lib/helpers.php
@@ -151,6 +151,9 @@ function generate_filename(string $content) {
$filename = hash("sha256", $content, false);
}
+ /* Ensure the new filename only contains valid characters */
+ $filename = validate_input_string($filename);
+
/* ensure filename as a proper file extension */
$filename = $filename . ".txt";
diff --git a/lib/list.php b/lib/list.php
@@ -93,6 +93,49 @@ function list_notes(
>
</form>
+ <!-- separator -->
+ <span class="inline">|</span>
+
+ <!-- delete button -->
+<?php
+ $del_id = hash(
+ "sha256",
+ $user . "/" . $filename["category"] . "/" . $filename["name"],
+ false
+ );
+?>
+ <form
+ action="/"
+ method="post"
+ id="<?php echo $del_id; ?>"
+ class="inline"
+ >
+ <input
+ id="category"
+ name="category"
+ type="hidden"
+ value="<?php echo $filename["category"]; ?>"
+ >
+ <input
+ id="filename"
+ name="filename"
+ type="hidden"
+ value="<?php echo $filename["name"] . ".txt"; ?>"
+ >
+ <input
+ id="action"
+ name="action"
+ type="hidden"
+ value="delete"
+ >
+ <input
+ class="danger likeanchor"
+ type="button"
+ value="<?php echo $GLOBALS["i18n_delete"]; ?>"
+ onclick="deletion_confirm('<?php echo $del_id; ?>');"
+ >
+ </form>
+
</div>
<?php
diff --git a/lib/show.php b/lib/show.php
@@ -71,7 +71,6 @@ function show_note(
>
</form>
-
<?php
} // function