openvk/Web/Presenters/ThemepacksPresenter.php
Alexander Minkin 6ec54a379d
feat: add linting of code (#1220)
* feat(lint): add php-cs-fixer for linting

Removing previous CODE_STYLE as it was not enforced anyway and using PER-CS 2.0.

This is not the reformatting commit.

* style: format code according to PER-CS 2.0 with php-cs-fixer

* ci(actions): add lint action

Resolves #1132.
2025-01-31 18:20:13 +03:00

42 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace openvk\Web\Presenters;
use openvk\Web\Themes\Themepacks;
final class ThemepacksPresenter extends OpenVKPresenter
{
protected $banTolerant = true;
public 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(chandler_escape_url($resource));
} elseif ($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) ?? "text/plain; charset=unknown-8bit");
header("Content-Size: " . strlen($data));
header("Cache-Control: public, no-transform, max-age=31536000");
exit($data);
}
}