Naprawa lokalizacji - odczytu
This commit is contained in:
23
public/includes/asset_version.php
Normal file
23
public/includes/asset_version.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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');
|
||||
}
|
||||
Reference in New Issue
Block a user