/** * Generate the templated content for a PHP script that can serve up the * given piece of content with the given age and expiry. * * @param string $content * @param string $age * @param string $lastModified * @param string $contentType * * @return string */ protected function generatePHPCacheFile($content, $age, $lastModified, $contentType) { $template = file_get_contents(dirname(__FILE__) . '/CachedPHPPage.tmpl'); $csrfPlaceholder = Config::inst()->get('LiveFilesystemPublisher', 'security_token_placeholder'); if (empty($csrfPlaceholder)) { $csrfPlaceholder = $csrfCode = 'DONT DO ANYTHING'; } else { $csrfCode = '<' . '?php echo $security_token; ?' . '>'; } return str_replace(array('**MAX_AGE**', '**LAST_MODIFIED**', '**CONTENT**', '**CONTENT_TYPE**', $csrfPlaceholder), array((int) $age, $lastModified, LivePubHelper::get_init_code_and_clear() . $content, $contentType, $csrfCode), $template); }