summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/partials.php5
-rw-r--r--public/index.php11
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/partials.php b/lib/partials.php
index e9b2263..489acae 100644
--- a/lib/partials.php
+++ b/lib/partials.php
@@ -15,6 +15,11 @@ function html_big_navbar()
<a href="/">
<button>Home</button>
</a>
+ <?php if (FILE_CATALOG_RANDOM): ?>
+ <a href="/?random">
+ <button>I'm Feeling Lucky</button>
+ </a>
+ <?php endif; ?>
<a href="/uploaders.php">
<button>Uploaders</button>
</a>
diff --git a/public/index.php b/public/index.php
index d6c759c..086bff4 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,6 +1,14 @@
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/partials.php';
+
+if (FILE_CATALOG_RANDOM && isset($_GET['random'])) {
+ $files = glob(FILE_UPLOAD_DIRECTORY . "/*.*");
+ $file = $files[random_int(0, count($files) - 1)];
+ $filename = basename($file);
+ header("Location: /{$filename}");
+ exit();
+}
?>
<html>
@@ -80,7 +88,8 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/partials.php';
<ul class="row gap-8 font-small" style="list-style:none">
<li>
<p class="font-small">Max file size:
- <b><?= get_cfg_var(option: 'upload_max_filesize') ?></b></p>
+ <b><?= get_cfg_var(option: 'upload_max_filesize') ?></b>
+ </p>
</li>
<li><a href="/uploaders.php#supported-file-extensions" target="_blank">Supported file
extensions</a></li>