summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-06-18 15:19:21 +0500
committerilotterytea <iltsu@alright.party>2025-06-18 15:19:21 +0500
commitaeff80740333ec49d13638f36b2bc74bc820404c (patch)
tree16daf7a82b950bc278383828e50cf410a6e9f7f9
parent70f40b94ad7f2d9eeb82a9313049e96d8fbc068d (diff)
feat: set file password
-rw-r--r--public/index.php7
-rw-r--r--public/static/style.css6
-rw-r--r--public/upload.php2
3 files changed, 14 insertions, 1 deletions
diff --git a/public/index.php b/public/index.php
index a6fa197..9e3dc4e 100644
--- a/public/index.php
+++ b/public/index.php
@@ -334,6 +334,13 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt');
</td>
</tr>
<tr>
+ <th>Password<span class="help" title="For file deletion">[?]</span>:</th>
+ <td><input type="text" name="password"
+ placeholder="Leave empty if you want the file to be non-deletable"
+ value="<?= generate_random_char_sequence(FILE_ID_CHARACTERS, FILE_DELETION_KEY_LENGTH) ?>">
+ </td>
+ </tr>
+ <tr>
<th>Preserve original filename:</th>
<td><input type="checkbox" name="preserve_original_name" value="1"></td>
</tr>
diff --git a/public/static/style.css b/public/static/style.css
index 2194b28..1d640a3 100644
--- a/public/static/style.css
+++ b/public/static/style.css
@@ -364,4 +364,10 @@ button[type=submit].fancy:hover {
.font-small {
font-size: 10px;
+}
+
+.help {
+ cursor: help;
+ font-size: 10px;
+ vertical-align: top;
} \ No newline at end of file
diff --git a/public/upload.php b/public/upload.php
index 8ad01e1..f578631 100644
--- a/public/upload.php
+++ b/public/upload.php
@@ -242,7 +242,7 @@ try {
'download_url' => INSTANCE_URL . "/{$file_data['id']}.{$file_data['extension']}"
];
- if (FILE_DELETION) {
+ if (FILE_DELETION && !empty($_POST['password'])) {
$file_data['password'] = $_POST['password'] ?? generate_random_char_sequence(FILE_ID_CHARACTERS, FILE_DELETION_KEY_LENGTH);
$file_data['urls']['deletion_url'] = INSTANCE_URL . "/delete.php?f={$file_data['id']}.{$file_data['extension']}&key={$file_data['password']}";
}