+++ /dev/null
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-/**\r
- * Prepend the cache information to the cache file\r
- * and write it\r
- *\r
- * @param string $tpl_file\r
- * @param string $cache_id\r
- * @param string $compile_id\r
- * @param string $results\r
- * @return true|null\r
- */\r
-\r
- // $tpl_file, $cache_id, $compile_id, $results\r
-\r
-function smarty_core_write_cache_file($params, &$smarty)\r
-{\r
-\r
- // put timestamp in cache header\r
- $smarty->_cache_info['timestamp'] = time();\r
- if ($smarty->cache_lifetime > -1){\r
- // expiration set\r
- $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;\r
- } else {\r
- // cache will never expire\r
- $smarty->_cache_info['expires'] = -1;\r
- }\r
-\r
- // collapse {nocache...}-tags\r
- $params['results'] = preg_replace('!((\{nocache\:([0-9a-f]{32})#(\d+)\})'\r
- .'.*'\r
- .'{/nocache\:\\3#\\4\})!Us'\r
- ,'\\2'\r
- ,$params['results']);\r
- $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;\r
-\r
- // prepend the cache header info into cache file\r
- $params['results'] = serialize($smarty->_cache_info)."\n".$params['results'];\r
-\r
- if (!empty($smarty->cache_handler_func)) {\r
- // use cache_handler function\r
- call_user_func_array($smarty->cache_handler_func,\r
- array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));\r
- } else {\r
- // use local cache file\r
-\r
- if(!@is_writable($smarty->cache_dir)) {\r
- // cache_dir not writable, see if it exists\r
- if(!@is_dir($smarty->cache_dir)) {\r
- $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);\r
- return false;\r
- }\r
- $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);\r
- return false;\r
- }\r
-\r
- $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);\r
- $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);\r
- $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);\r
- require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');\r
- smarty_core_write_file($_params, $smarty);\r
- return true;\r
- }\r
-}\r
-\r
-/* vim: set expandtab: */\r
-\r
-?>\r