25 $smarty->_cache_info[
'timestamp'] = time();
26 if ($smarty->cache_lifetime > -1){
28 $smarty->_cache_info[
'expires'] = $smarty->_cache_info[
'timestamp'] + $smarty->cache_lifetime;
31 $smarty->_cache_info[
'expires'] = -1;
35 if (preg_match_all(
'!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params[
'results'], $match, PREG_PATTERN_ORDER)) {
41 $match_count = count($match[0]);
42 $results = preg_split(
'!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params[
'results'], -1, PREG_SPLIT_DELIM_CAPTURE);
46 for (
$i=0, $results_count = count($results);
$i < $results_count &&
$j < $match_count;
$i++) {
47 if ($results[
$i] == $match[0][
$j]) {
53 if ($level++ > 0) unset($results[
$i]);
56 } elseif ($level > 0) {
60 $params[
'results'] = implode(
'', $results);
62 $smarty->_cache_info[
'cache_serials'] = $smarty->_cache_serials;
65 $_cache_info = serialize($smarty->_cache_info);
66 $params[
'results'] = strlen($_cache_info) .
"\n" . $_cache_info . $params[
'results'];
68 if (!empty($smarty->cache_handler_func)) {
70 call_user_func_array($smarty->cache_handler_func,
71 array(
'write', &$smarty, &$params[
'results'], $params[
'tpl_file'], $params[
'cache_id'], $params[
'compile_id'], $smarty->_cache_info[
'expires']));
75 if(!@is_writable($smarty->cache_dir)) {
77 if(!@is_dir($smarty->cache_dir)) {
78 $smarty->trigger_error(
'the $cache_dir \'' . $smarty->cache_dir .
'\' does not exist, or is not a directory.
', E_USER_ERROR);
81 $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);
85 $_auto_id = $smarty->_get_auto_id($params['cache_id
'], $params['compile_id
']);
86 $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file
'], $_auto_id);
87 $_params = array('filename
' => $_cache_file, 'contents
' => $params['results
'], 'create_dirs
' => true);
88 require_once(SMARTY_CORE_DIR . 'core.write_file.php
');
89 smarty_core_write_file($_params, $smarty);
94 /* vim: set expandtab: */