Wobbly-Website/set_background.php
2024-10-05 16:39:36 +02:00

21 lines
No EOL
591 B
PHP

<?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;
?>