check for / in filepath to make sure path doesn't get broken

This commit is contained in:
HB9HIL
2026-02-13 17:04:57 +01:00
parent 82cc0cf99d
commit 74d56d5f45

View File

@@ -34,11 +34,14 @@ class Paths
}
function cache_buster($filepath) {
// make sure $filepath starts with a slash
if (substr($filepath, 0, 1) !== '/') $filepath = '/' . $filepath;
$fullpath = $_SERVER['DOCUMENT_ROOT'] . $filepath;
if (file_exists($fullpath)) {
return base_url($filepath) . '?v=' . filemtime($fullpath);
} else {
log_message('error', 'CACHE BUSTER - File does not exist: ' . $filepath);
log_message('error', 'CACHE BUSTER: File does not exist: ' . $fullpath);
}
return base_url($filepath);
}