24 lines
578 B
PHP
24 lines
578 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Wersja statycznego pliku w public/ — timestamp modyfikacji (cache busting po FTP).
|
|
*/
|
|
function publicAssetVersion(string $publicDir, string $relativePath): string
|
|
{
|
|
$path = $publicDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, ltrim($relativePath, '/'));
|
|
if (!is_file($path)) {
|
|
return '0';
|
|
}
|
|
|
|
$mtime = filemtime($path);
|
|
|
|
return $mtime !== false ? (string) $mtime : '0';
|
|
}
|
|
|
|
function assetVersionAttr(string $version): string
|
|
{
|
|
return htmlspecialchars($version, ENT_QUOTES, 'UTF-8');
|
|
}
|