1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00
vichan/banners.php

32 lines
787 B
PHP
Raw Normal View History

2014-05-23 23:20:27 +02:00
<?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,30}$/', $b)))
return null;
2014-05-23 23:20:27 +02:00
# Check if directory exists
$dir = "static/banners/$b/";
if (!is_dir($dir))
return null;
2014-05-23 23:20:27 +02:00
# 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];
2014-05-23 23:20:27 +02:00
}
$banner = get_custom_banner($_GET['board']);
if ($banner)
header("Location: $banner");
else
header("Location: static/8chan banner.png");