Wobbly-Website/set_background.php

21 lines
591 B
PHP
Raw Permalink Normal View History

2024-10-05 16:39:36 +02:00
<?php
function scanAllDir($dir) {
$result = [];
foreach(scandir($dir) as $filename) {
if ($filename[0] === '.') continue;
$filePath = $dir . '/' . $filename;
if (is_dir($filePath)) {
foreach (scanAllDir($filePath) as $childFilename) {
$result[] = $filename . '/' . $childFilename;
}
} else {
$result[] = $filename;
}
}
return $result;
}
$backgrounds = scanAllDir("backgrounds");
$chosen_background = $backgrounds[array_rand($backgrounds)];
$chosen_background = "backgrounds/" . $chosen_background;
?>