mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
|
<?php declare(strict_types=1);
|
||
|
namespace openvk\Web\Presenters;
|
||
|
use openvk\Web\Themes\Themepacks;
|
||
|
|
||
|
final class ThemepacksPresenter extends OpenVKPresenter
|
||
|
{
|
||
|
protected $banTolerant = true;
|
||
|
|
||
|
function renderResource(string $themepack, string $version, string $resClass, string $resource): void
|
||
|
{
|
||
|
if(!isset(Themepacks::i()[$themepack]))
|
||
|
$this->notFound();
|
||
|
else
|
||
|
$theme = Themepacks::i()[$themepack];
|
||
|
|
||
|
if($resClass === "resource") {
|
||
|
$data = $theme->fetchStaticResource($resource);
|
||
|
} else if($resClass === "stylesheet") {
|
||
|
if($resource !== "styles.css")
|
||
|
$this->notFound();
|
||
|
else
|
||
|
$data = $theme->fetchStyleSheet();
|
||
|
} else {
|
||
|
$this->notFound();
|
||
|
}
|
||
|
|
||
|
if(!$data)
|
||
|
$this->notFound();
|
||
|
|
||
|
header("Content-Type: " . system_extension_mime_type($resource));
|
||
|
header("Content-Size: " . strlen($data));
|
||
|
header("Cache-Control: public, no-transform, max-age=31536000");
|
||
|
exit($data);
|
||
|
}
|
||
|
}
|