forked from leftypol/leftypol
banners.php: make banners redirect instead of serving the image directly
This commit is contained in:
parent
45e4153d5b
commit
295d1751b1
1 changed files with 5 additions and 13 deletions
18
banners.php
18
banners.php
|
@ -1,16 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
function getBannerSrc(){
|
|
||||||
$files = scandir(__dir__.'/banners/');
|
|
||||||
$files = array_diff($files, array('.', '..'));
|
|
||||||
return $files[array_rand($files)];
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = getBannerSrc();
|
$files = scandir(__dir__ . '/banners/', SCANDIR_SORT_NONE);
|
||||||
$filename = "banners/" . $filename;
|
$files = array_diff($files, ['.', '..']);
|
||||||
$fp = fopen($filename, 'rb');
|
|
||||||
|
|
||||||
header("Content-Type: image/png");
|
$filename = $files[array_rand($files)];
|
||||||
header("Content-Length: " . filesize($filename));
|
header("Location: /banners/$filename", true, 307);
|
||||||
|
header('Cache-Control: no-cache');
|
||||||
fpassthru($fp);
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue