<?
AddEventHandler("main", "OnEndBufferContent", array("CMainHandlers", "OnEndBufferContentHandler"));
class CMainHandlers
{
function OnEndBufferContentHandler($content)
{
$reg = '/(?:href|src)="(?!http)(?!\/\/)([^"]+.(?:js|css))"/sim';
preg_match_all($reg, $content, $arr);
$arr[1] = array_unique($arr[1]);
foreach($arr[1] as $key => $el){
$fullpath = $_SERVER["DOCUMENT_ROOT"].$el;
if(file_exists($fullpath) && !strpos($el, "?")){
$content = str_replace($el, $el."?".filemtime($fullpath), $content);
}
}
}
}
?>
|