32 lines
1.4 KiB
PHP
32 lines
1.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Das Handbuch (PDF) für Administratoren: Adminportal → Hilfe (staff/help.php).
|
|
* Die Datei kommt mit jedem Update im Programmpaket mit (docs/DeskHub-Handbuch.pdf). Der Ordner docs/ ist für den Webserver gesperrt
|
|
* (.htaccess bzw. die nginx-Regeln); ausgeliefert wird die Datei nur über die Hilfe-Seite an echte Administratoren.
|
|
*/
|
|
|
|
const MANUAL_FILE = 'DeskHub-Handbuch.pdf';
|
|
|
|
function manual_path(): string
|
|
{
|
|
return (string) (getenv('DESKHUB_MANUAL_PATH') ?: dirname(__DIR__) . '/docs/' . MANUAL_FILE);
|
|
}
|
|
|
|
/** @return array{size:int,modified_at:string,sha256:string}|null */
|
|
function manual_info(): ?array
|
|
{
|
|
$path = manual_path();
|
|
if (!is_file($path)) return null;
|
|
$size = (int) filesize($path);
|
|
$mtime = (int) filemtime($path);
|
|
// Die Prüfsumme wird nur neu berechnet, wenn sich Größe oder Änderungsdatum ändern
|
|
$cache = json_decode((string) get_setting('manual_file_cache', ''), true);
|
|
if (!is_array($cache) || (int) ($cache['size'] ?? -1) !== $size || (int) ($cache['mtime'] ?? -1) !== $mtime || empty($cache['sha256'])) {
|
|
$cache = ['size' => $size, 'mtime' => $mtime, 'sha256' => (string) hash_file('sha256', $path)];
|
|
set_setting('manual_file_cache', json_encode($cache));
|
|
}
|
|
return ['size' => $size, 'modified_at' => date('Y-m-d H:i:s', $mtime), 'sha256' => (string) $cache['sha256']];
|
|
}
|