' ) { return true; } else { return false; } } /* * Basic file versioning * Note: probably better to use `md5_file` instead of `filemtime` * http://www.php.net/manual/en/function.md5-file.php */ function version($filename) { // get the absolute path to the file $pathToFile = TEMPLATEPATH . '/' . $filename; //check if the file exists if (file_exists($pathToFile)) { $needle = '.'; // return the versioned filename based on the last modified time $versioned = '.' . filemtime($pathToFile) . '.'; // the position of the last instance of '.' $pos = strrpos($filename, $needle); if ($pos !== false) { // replace and return return '/' . substr_replace($filename, $versioned, $pos, strlen($needle)); } } else { // return the original filename return '/' . $filename; } } ?>