Files
marianek.pl/autoload/admin/Controllers/FilemanagerController.php
Jacek Pyziak fc45bbf20e Add view classes for articles, banners, languages, menu, newsletter, containers, shop categories, clients, payment methods, products, and search
- Created `Articles` class for rendering article views including full articles, miniature lists, and news sections.
- Added `Banners` class for handling banner displays.
- Introduced `Languages` class for rendering language options.
- Implemented `Menu` class for rendering page and menu structures.
- Developed `Newsletter` class for newsletter rendering.
- Created `Scontainers` class for rendering specific containers.
- Added `ShopCategory` class for managing shop category views and pagination.
- Implemented `ShopClient` class for client-related views including address management and login forms.
- Created `ShopPaymentMethod` class for displaying payment methods in the basket.
- Added `ShopProduct` class for generating product URLs.
- Introduced `ShopSearch` class for rendering a simple search form.
- Added `.htaccess` file in the plugins directory to enhance security by restricting access to sensitive files and directories.
2026-02-21 23:00:54 +01:00

47 lines
1.3 KiB
PHP

<?php
namespace admin\Controllers;
class FilemanagerController
{
private const RFM_KEY_TTL = 1200; // 20 min
private const FILEMANAGER_DIALOG_PATH = '/libraries/filemanager-9.14.2/dialog.php';
public function draw(): string
{
$akey = $this->ensureFilemanagerAccessKey();
$filemanagerUrl = $this->buildFilemanagerUrl($akey);
return \Shared\Tpl\Tpl::view('filemanager/filemanager', [
'filemanager_url' => $filemanagerUrl,
]);
}
private function ensureFilemanagerAccessKey(): string
{
$expiresAt = (int)($_SESSION['rfm_akey_expires'] ?? 0);
$existingKey = trim((string)($_SESSION['rfm_akey'] ?? ''));
if ($existingKey !== '' && $expiresAt >= time()) {
$_SESSION['rfm_akey_expires'] = time() + self::RFM_KEY_TTL;
return $existingKey;
}
try {
$newKey = bin2hex(random_bytes(16));
} catch (\Throwable $e) {
$newKey = sha1(uniqid('rfm', true));
}
$_SESSION['rfm_akey'] = $newKey;
$_SESSION['rfm_akey_expires'] = time() + self::RFM_KEY_TTL;
return $newKey;
}
private function buildFilemanagerUrl(string $akey): string
{
return self::FILEMANAGER_DIALOG_PATH . '?akey=' . rawurlencode($akey);
}
}