diff options
| author | ilotterytea <iltsu@alright.party> | 2025-10-05 20:58:26 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-10-05 20:58:26 +0500 |
| commit | 512783782f87fef2be2d70bbd301e1b73c361fff (patch) | |
| tree | da26dd251848209bab8f64e24e44bc8bda826f2f | |
| parent | cf4d0517e831ed713bbc345abb7fcb8dc221547d (diff) | |
feat: set specific order for random files
| -rw-r--r-- | public/index.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/public/index.php b/public/index.php index f4d8e51..7aeff6e 100644 --- a/public/index.php +++ b/public/index.php @@ -24,11 +24,10 @@ if (FILE_CATALOG_RANDOM && isset($_GET['random'])) { $in = !empty($random_viewed_files) ? (str_repeat('?,', count($random_viewed_files) - 1) . '?') : ''; $in_condition = !empty($random_viewed_files) ? ("id NOT IN ($in) " . ($mime_filter ? " AND " : "")) : ""; $where_word = $in_condition || $mime_filter ? "WHERE" : ""; - - error_log("SELECT id, extension FROM files $where_word $in_condition $mime_filter ORDER BY rand() LIMIT 1"); + $order_condition = FILE_CATALOG_RANDOM_ORDER ?: "rand()"; do { - $stmt = $db->prepare("SELECT id, extension FROM files $where_word $in_condition $mime_filter ORDER BY rand() LIMIT 1"); + $stmt = $db->prepare("SELECT id, extension FROM files $where_word $in_condition $mime_filter ORDER BY $order_condition LIMIT 1"); if (empty($random_viewed_files)) { $stmt->execute(); } else { |
