forked from leftypol/leftypol
Adds banner support and banners
This commit is contained in:
parent
f9a6b584e1
commit
e48982cf41
27 changed files with 16 additions and 19 deletions
32
banners.php
32
banners.php
|
@ -1,22 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Lainchan Banners</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
function listBannersInDir($dir) {
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != "..") {
|
||||
echo "<a href=\"$dir/$entry\"><img src=\"$dir/$entry\" alt=\"$entry\" style=\"width:348px;height:128px\"></a> ";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
function getBannerSrc(){
|
||||
$files = scandir(__dir__.'/banners/');
|
||||
$files = array_diff($files, array('.', '..'));
|
||||
return $files[array_rand($files)];
|
||||
}
|
||||
|
||||
listBannersInDir("banners_priority");
|
||||
listBannersInDir("banners");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
$filename = getBannerSrc();
|
||||
$filename = "banners/" . $filename;
|
||||
$fp = fopen($filename, 'rb');
|
||||
|
||||
header("Content-Type: image/png");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
|
||||
fpassthru($fp);
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue