21 lines
No EOL
591 B
PHP
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;
|
|
?>
|