|
@@ -30,6 +30,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
redirect('gallery-edit.php?g=' . rawurlencode($slug));
|
|
redirect('gallery-edit.php?g=' . rawurlencode($slug));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ($action === 'uploads') {
|
|
|
|
|
+ $mode = (string)($_POST['mode'] ?? '');
|
|
|
|
|
+ if ($mode === 'enable' && empty($gallery['upload_key'])) {
|
|
|
|
|
+ $gallery['upload_key'] = random_token(24);
|
|
|
|
|
+ gallery_save($gallery);
|
|
|
|
|
+ flash_set('Guest uploads enabled.');
|
|
|
|
|
+ } elseif ($mode === 'regenerate') {
|
|
|
|
|
+ $gallery['upload_key'] = random_token(24);
|
|
|
|
|
+ gallery_save($gallery);
|
|
|
|
|
+ flash_set('New upload link generated; the old link no longer works.');
|
|
|
|
|
+ } elseif ($mode === 'disable') {
|
|
|
|
|
+ $gallery['upload_key'] = null;
|
|
|
|
|
+ gallery_save($gallery);
|
|
|
|
|
+ flash_set('Guest uploads disabled.');
|
|
|
|
|
+ }
|
|
|
|
|
+ redirect('gallery-edit.php?g=' . rawurlencode($slug));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ($action === 'delete-image') {
|
|
if ($action === 'delete-image') {
|
|
|
$key = (string)($_POST['key'] ?? '');
|
|
$key = (string)($_POST['key'] ?? '');
|
|
|
foreach ($gallery['images'] ?? [] as $i => $img) {
|
|
foreach ($gallery['images'] ?? [] as $i => $img) {
|
|
@@ -56,6 +74,11 @@ $host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
|
$basePath = str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME'] ?? '/admin/gallery-edit.php')));
|
|
$basePath = str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME'] ?? '/admin/gallery-edit.php')));
|
|
|
$basePath = rtrim($basePath, '/');
|
|
$basePath = rtrim($basePath, '/');
|
|
|
$shareUrl = $scheme . '://' . $host . $basePath . '/gallery.php?g=' . rawurlencode($slug);
|
|
$shareUrl = $scheme . '://' . $host . $basePath . '/gallery.php?g=' . rawurlencode($slug);
|
|
|
|
|
+// Guest upload link (only when a key is set). Same host/path derivation as above.
|
|
|
|
|
+$uploadUrl = !empty($gallery['upload_key'])
|
|
|
|
|
+ ? $scheme . '://' . $host . $basePath . '/upload.php?g=' . rawurlencode($slug)
|
|
|
|
|
+ . '&k=' . rawurlencode($gallery['upload_key'])
|
|
|
|
|
+ : '';
|
|
|
|
|
|
|
|
admin_header($gallery['title'], 'galleries');
|
|
admin_header($gallery['title'], 'galleries');
|
|
|
flash_render();
|
|
flash_render();
|
|
@@ -80,6 +103,45 @@ flash_render();
|
|
|
<div class="upload-list" id="upload-list"></div>
|
|
<div class="upload-list" id="upload-list"></div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+<div class="card">
|
|
|
|
|
+ <h2 style="margin-top:0">Guest uploads</h2>
|
|
|
|
|
+ <?php if ($uploadUrl !== ''): ?>
|
|
|
|
|
+ <p class="help" style="margin-bottom:1rem">
|
|
|
|
|
+ Share this link so guests can upload into this gallery without an admin
|
|
|
|
|
+ account. It is key-protected and honors the gallery's password and
|
|
|
|
|
+ expiry, if set.
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p style="margin-bottom:1rem">
|
|
|
|
|
+ <a href="<?= e($uploadUrl) ?>" target="_blank" rel="noopener"><?= e($uploadUrl) ?></a>
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <form method="post" style="display:inline"
|
|
|
|
|
+ onsubmit="return confirm('Generate a new link? The current link will stop working.')">
|
|
|
|
|
+ <?= csrf_field() ?>
|
|
|
|
|
+ <input type="hidden" name="action" value="uploads">
|
|
|
|
|
+ <input type="hidden" name="mode" value="regenerate">
|
|
|
|
|
+ <button style="margin:0">Regenerate link</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <form method="post" style="display:inline"
|
|
|
|
|
+ onsubmit="return confirm('Disable guest uploads? The link will stop working.')">
|
|
|
|
|
+ <?= csrf_field() ?>
|
|
|
|
|
+ <input type="hidden" name="action" value="uploads">
|
|
|
|
|
+ <input type="hidden" name="mode" value="disable">
|
|
|
|
|
+ <button class="btn-danger" style="margin:0">Disable</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php else: ?>
|
|
|
|
|
+ <p class="help" style="margin-bottom:1rem">
|
|
|
|
|
+ Guest uploads are disabled. Enable them to get a shareable link that
|
|
|
|
|
+ lets people upload into this gallery without an admin account.
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <form method="post">
|
|
|
|
|
+ <?= csrf_field() ?>
|
|
|
|
|
+ <input type="hidden" name="action" value="uploads">
|
|
|
|
|
+ <input type="hidden" name="mode" value="enable">
|
|
|
|
|
+ <button style="margin:0">Enable guest uploads</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+</div>
|
|
|
|
|
+
|
|
|
<form method="post" class="card">
|
|
<form method="post" class="card">
|
|
|
<?= csrf_field() ?>
|
|
<?= csrf_field() ?>
|
|
|
<input type="hidden" name="action" value="settings">
|
|
<input type="hidden" name="action" value="settings">
|