forked from ctrlcctrlv/infinity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanners.php
31 lines (26 loc) · 786 Bytes
/
banners.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?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");