mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-25 07:50:23 +01:00
78f1a99820
Removed unnecessary import. Added a function to avoid duplicating code.
32 lines
786 B
PHP
32 lines
786 B
PHP
<?php
|
|
|
|
header("Pragma-directive: no-cache");
|
|
header("Cache-directive: no-cache");
|
|
header("Cache-control: no-cache");
|
|
header("Pragma: no-cache");
|
|
header("Expires: 0");
|
|
|
|
function get_custom_banner(&$b) {
|
|
# Validate the board name
|
|
if (!(isset($b) && preg_match('/^[a-z0-9]{1,10}$/', $b)))
|
|
return null;
|
|
|
|
# Check if directory exists
|
|
$dir = "static/banners/$b/";
|
|
if (!is_dir($dir))
|
|
return null;
|
|
|
|
# Return random file if directory is not empty
|
|
$banners = array_diff(scandir($dir), array('..', '.'));
|
|
if (!$banners)
|
|
return null;
|
|
$r = array_rand($banners);
|
|
return $dir.$banners[$r];
|
|
}
|
|
|
|
$banner = get_custom_banner($_GET['board']);
|
|
if ($banner)
|
|
header("Location: $banner");
|
|
else
|
|
header("Location: static/8chan banner.png");
|