mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-27 17:00:52 +01:00
f631b83fb1
PHP 7.4 Notice: Trying to access array offset on value of type resource in on line 13 Notice: Trying to access array offset on value of type resource in on line 14 Notice: fpassthru(): read of 8192 bytes failed with errno=21 Is a directory in on line 17
21 lines
594 B
PHP
21 lines
594 B
PHP
<?php
|
|
$dir = "static/banners/";
|
|
$files = scandir($dir, SCANDIR_SORT_NONE);
|
|
$images = array_diff($files, array('.', '..'));
|
|
$name = $images[array_rand($images)];
|
|
// open the file in a binary mode
|
|
$fp = fopen($dir . $name, 'rb');
|
|
|
|
// send the right headers
|
|
header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1
|
|
header('Pragma: no-cache'); // HTTP 1.0
|
|
header('Expires: 0'); // Proxies
|
|
$fstat = fstat($fp);
|
|
header('Content-Type: ' . mime_content_type($dir . $name));
|
|
header('Content-Length: ' . $fstat['size']);
|
|
|
|
// dump the picture and stop the script
|
|
fpassthru($fp);
|
|
exit;
|
|
?>
|