update Smarty to 3.1.21
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1704 a1433add-5e2c-0410-b055-b7f2511e0802pull/2/head
parent
6ec360b0b7
commit
49be08c9fe
File diff suppressed because it is too large
Load Diff
@ -1,133 +1,137 @@
|
|||||||
{capture name='_smarty_debug' assign=debug_output}
|
{capture name='_smarty_debug' assign=debug_output}
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Smarty Debug Console</title>
|
<title>Smarty Debug Console</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
{literal}
|
{literal}
|
||||||
body, h1, h2, td, th, p {
|
body, h1, h2, td, th, p {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
background-color: #f0c040;
|
background-color: #f0c040;
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
background-color: #9B410E;
|
background-color: #9B410E;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
border-top: 1px solid black;
|
border-top: 1px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: black;
|
background: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
p, table, div {
|
p, table, div {
|
||||||
background: #f0ead8;
|
background: #f0ead8;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.odd {
|
.odd {
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.even {
|
.even {
|
||||||
background-color: #fafafa;
|
background-color: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.exectime {
|
.exectime {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
#table_assigned_vars th {
|
#table_assigned_vars th {
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#table_config_vars th {
|
#table_config_vars th {
|
||||||
color: maroon;
|
color: maroon;
|
||||||
}
|
}
|
||||||
{/literal}
|
|
||||||
</style>
|
{/literal}
|
||||||
</head>
|
</style>
|
||||||
<body>
|
</head>
|
||||||
|
<body>
|
||||||
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
|
||||||
|
<h1>Smarty Debug Console
|
||||||
{if !empty($template_data)}
|
- {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||||
<h2>included templates & config files (load time in seconds)</h2>
|
|
||||||
|
{if !empty($template_data)}
|
||||||
<div>
|
<h2>included templates & config files (load time in seconds)</h2>
|
||||||
{foreach $template_data as $template}
|
<div>
|
||||||
<font color=brown>{$template.name}</font>
|
{foreach $template_data as $template}
|
||||||
<span class="exectime">
|
<font color=brown>{$template.name}</font>
|
||||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
<span class="exectime">
|
||||||
|
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}
|
||||||
|
)
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2>assigned template variables</h2>
|
<h2>assigned template variables</h2>
|
||||||
|
|
||||||
<table id="table_assigned_vars">
|
<table id="table_assigned_vars">
|
||||||
{foreach $assigned_vars as $vars}
|
{foreach $assigned_vars as $vars}
|
||||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||||
<th>${$vars@key|escape:'html'}</th>
|
<th>${$vars@key|escape:'html'}</th>
|
||||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
<td>{$vars|debug_print_var nofilter}</td>
|
||||||
{/foreach}
|
</tr>
|
||||||
</table>
|
{/foreach}
|
||||||
|
</table>
|
||||||
<h2>assigned config file variables (outer template scope)</h2>
|
|
||||||
|
<h2>assigned config file variables (outer template scope)</h2>
|
||||||
<table id="table_config_vars">
|
|
||||||
{foreach $config_vars as $vars}
|
<table id="table_config_vars">
|
||||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
{foreach $config_vars as $vars}
|
||||||
<th>{$vars@key|escape:'html'}</th>
|
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||||
<td>{$vars|debug_print_var nofilter}</td></tr>
|
<th>{$vars@key|escape:'html'}</th>
|
||||||
{/foreach}
|
<td>{$vars|debug_print_var nofilter}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
{/foreach}
|
||||||
</body>
|
|
||||||
</html>
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
{/capture}
|
{/capture}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{$id = $template_name|default:''|md5}
|
{$id = $template_name|default:''|md5}
|
||||||
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
|
_smarty_console = window.open("", "console{$id}", "width=680,height=600,resizable,scrollbars=yes");
|
||||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||||
_smarty_console.document.close();
|
_smarty_console.document.close();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,25 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty plugin
|
* Smarty plugin
|
||||||
* @package Smarty
|
*
|
||||||
|
* @package Smarty
|
||||||
* @subpackage PluginsModifier
|
* @subpackage PluginsModifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty spacify modifier plugin
|
* Smarty spacify modifier plugin
|
||||||
*
|
|
||||||
* Type: modifier<br>
|
* Type: modifier<br>
|
||||||
* Name: spacify<br>
|
* Name: spacify<br>
|
||||||
* Purpose: add spaces between characters in a string
|
* Purpose: add spaces between characters in a string
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
|
*
|
||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
* @param string $spacify_char string to insert between characters.
|
* @param string $spacify_char string to insert between characters.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||||
{
|
{
|
||||||
// well… what about charsets besides latin and UTF-8?
|
// well… what about charsets besides latin and UTF-8?
|
||||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,277 +1,297 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin CacheResource File
|
* Smarty Internal Plugin CacheResource File
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Cacher
|
* @subpackage Cacher
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class does contain all necessary methods for the HTML cache on file system
|
||||||
|
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Cacher
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* This class does contain all necessary methods for the HTML cache on file system
|
* populate Cached Object with meta data from Resource
|
||||||
*
|
*
|
||||||
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
*
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @package Smarty
|
*
|
||||||
* @subpackage Cacher
|
* @return void
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
||||||
{
|
{
|
||||||
/**
|
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
|
||||||
* populate Cached Object with meta data from Resource
|
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
|
||||||
*
|
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
$_filepath = $_template->source->uid;
|
||||||
* @param Smarty_Internal_Template $_template template object
|
// if use_sub_dirs, break file into directories
|
||||||
* @return void
|
if ($_template->smarty->use_sub_dirs) {
|
||||||
*/
|
$_filepath = substr($_filepath, 0, 2) . DS
|
||||||
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
|
||||||
{
|
|
||||||
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
|
|
||||||
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
|
|
||||||
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
|
|
||||||
$_filepath = $_template->source->uid;
|
|
||||||
// if use_sub_dirs, break file into directories
|
|
||||||
if ($_template->smarty->use_sub_dirs) {
|
|
||||||
$_filepath = substr($_filepath, 0, 2) . DS
|
|
||||||
. substr($_filepath, 2, 2) . DS
|
. substr($_filepath, 2, 2) . DS
|
||||||
. substr($_filepath, 4, 2) . DS
|
. substr($_filepath, 4, 2) . DS
|
||||||
. $_filepath;
|
. $_filepath;
|
||||||
}
|
}
|
||||||
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
||||||
if (isset($_cache_id)) {
|
if (isset($_cache_id)) {
|
||||||
$_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
|
$_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
|
||||||
} else {
|
} else {
|
||||||
$_cache_id = '';
|
$_cache_id = '';
|
||||||
}
|
}
|
||||||
if (isset($_compile_id)) {
|
if (isset($_compile_id)) {
|
||||||
$_compile_id = $_compile_id . $_compile_dir_sep;
|
$_compile_id = $_compile_id . $_compile_dir_sep;
|
||||||
|
} else {
|
||||||
|
$_compile_id = '';
|
||||||
|
}
|
||||||
|
$_cache_dir = $_template->smarty->getCacheDir();
|
||||||
|
if ($_template->smarty->cache_locking) {
|
||||||
|
// create locking file name
|
||||||
|
// relative file name?
|
||||||
|
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_cache_dir)) {
|
||||||
|
$_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
|
||||||
} else {
|
} else {
|
||||||
$_compile_id = '';
|
$_lock_dir = $_cache_dir;
|
||||||
}
|
|
||||||
$_cache_dir = $_template->smarty->getCacheDir();
|
|
||||||
if ($_template->smarty->cache_locking) {
|
|
||||||
// create locking file name
|
|
||||||
// relative file name?
|
|
||||||
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_cache_dir)) {
|
|
||||||
$_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
|
|
||||||
} else {
|
|
||||||
$_lock_dir = $_cache_dir;
|
|
||||||
}
|
|
||||||
$cached->lock_id = $_lock_dir.sha1($_cache_id.$_compile_id.$_template->source->uid).'.lock';
|
|
||||||
}
|
}
|
||||||
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
$cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock';
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
|
||||||
$cached->exists = !!$cached->timestamp;
|
|
||||||
}
|
}
|
||||||
|
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
||||||
|
$cached->timestamp = @filemtime($cached->filepath);
|
||||||
|
$cached->exists = !!$cached->timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate Cached Object with timestamp and exists from Resource
|
* populate Cached Object with timestamp and exists from Resource
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @return void
|
*
|
||||||
*/
|
* @return void
|
||||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
*/
|
||||||
{
|
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
{
|
||||||
$cached->exists = !!$cached->timestamp;
|
$cached->timestamp = @filemtime($cached->filepath);
|
||||||
}
|
$cached->exists = !!$cached->timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the cached template and process its header
|
* Read the cached template and process its header
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @return booelan true or false if the cached content does not exist
|
*
|
||||||
*/
|
* @return booleantrue or false if the cached content does not exist
|
||||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
|
*/
|
||||||
{
|
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
|
||||||
$_smarty_tpl = $_template;
|
{
|
||||||
|
/** @var Smarty_Internal_Template $_smarty_tpl
|
||||||
|
* used in included file
|
||||||
|
*/
|
||||||
|
$_smarty_tpl = $_template;
|
||||||
|
|
||||||
return @include $_template->cached->filepath;
|
return @include $_template->cached->filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the rendered template output to cache
|
* Write the rendered template output to cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @param string $content content to cache
|
* @param string $content content to cache
|
||||||
* @return boolean success
|
*
|
||||||
*/
|
* @return boolean success
|
||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
*/
|
||||||
{
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
{
|
||||||
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||||
$_template->cached->exists = !!$_template->cached->timestamp;
|
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
||||||
if ($_template->cached->exists) {
|
$_template->cached->exists = !!$_template->cached->timestamp;
|
||||||
return true;
|
if ($_template->cached->exists) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
* Empty cache
|
}
|
||||||
*
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
|
||||||
* @return integer number of cache files deleted
|
|
||||||
*/
|
|
||||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
|
||||||
{
|
|
||||||
return $this->clear($smarty, null, null, null, $exp_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty cache for a specific template
|
* Empty cache
|
||||||
*
|
*
|
||||||
* @param Smarty $_template template object
|
* @param Smarty $smarty
|
||||||
* @param string $resource_name template name
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
* @param string $cache_id cache id
|
*
|
||||||
* @param string $compile_id compile id
|
* @return integer number of cache files deleted
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
*/
|
||||||
* @return integer number of cache files deleted
|
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||||
*/
|
{
|
||||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
return $this->clear($smarty, null, null, null, $exp_time);
|
||||||
{
|
}
|
||||||
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
|
||||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
/**
|
||||||
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
* Empty cache for a specific template
|
||||||
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
*
|
||||||
$_dir = $smarty->getCacheDir();
|
* @param Smarty $smarty
|
||||||
$_dir_length = strlen($_dir);
|
* @param string $resource_name template name
|
||||||
if (isset($_cache_id)) {
|
* @param string $cache_id cache id
|
||||||
$_cache_id_parts = explode('|', $_cache_id);
|
* @param string $compile_id compile id
|
||||||
$_cache_id_parts_count = count($_cache_id_parts);
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
if ($smarty->use_sub_dirs) {
|
*
|
||||||
foreach ($_cache_id_parts as $id_part) {
|
* @return integer number of cache files deleted
|
||||||
$_dir .= $id_part . DS;
|
*/
|
||||||
}
|
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||||
|
{
|
||||||
|
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
||||||
|
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
||||||
|
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
||||||
|
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
||||||
|
if (($_dir = realpath($smarty->getCacheDir())) === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$_dir .= '/';
|
||||||
|
$_dir_length = strlen($_dir);
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
$_cache_id_parts = explode('|', $_cache_id);
|
||||||
|
$_cache_id_parts_count = count($_cache_id_parts);
|
||||||
|
if ($smarty->use_sub_dirs) {
|
||||||
|
foreach ($_cache_id_parts as $id_part) {
|
||||||
|
$_dir .= $id_part . DS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($resource_name)) {
|
}
|
||||||
$_save_stat = $smarty->caching;
|
if (isset($resource_name)) {
|
||||||
$smarty->caching = true;
|
$_save_stat = $smarty->caching;
|
||||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
$smarty->caching = true;
|
||||||
$smarty->caching = $_save_stat;
|
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||||
|
$smarty->caching = $_save_stat;
|
||||||
|
|
||||||
// remove from template cache
|
// remove from template cache
|
||||||
$tpl->source; // have the template registered before unset()
|
$tpl->source; // have the template registered before unset()
|
||||||
if ($smarty->allow_ambiguous_resources) {
|
if ($smarty->allow_ambiguous_resources) {
|
||||||
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
||||||
} else {
|
} else {
|
||||||
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
||||||
}
|
}
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
unset($smarty->template_objects[$_templateId]);
|
unset($smarty->template_objects[$_templateId]);
|
||||||
|
|
||||||
if ($tpl->source->exists) {
|
if ($tpl->source->exists) {
|
||||||
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$_count = 0;
|
}
|
||||||
$_time = time();
|
$_count = 0;
|
||||||
if (file_exists($_dir)) {
|
$_time = time();
|
||||||
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
if (file_exists($_dir)) {
|
||||||
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
||||||
foreach ($_cache as $_file) {
|
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
foreach ($_cache as $_file) {
|
||||||
// directory ?
|
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||||
if ($_file->isDir()) {
|
continue;
|
||||||
if (!$_cache->isDot()) {
|
}
|
||||||
// delete folder if empty
|
// directory ?
|
||||||
@rmdir($_file->getPathname());
|
if ($_file->isDir()) {
|
||||||
}
|
if (!$_cache->isDot()) {
|
||||||
} else {
|
// delete folder if empty
|
||||||
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
|
@rmdir($_file->getPathname());
|
||||||
$_parts_count = count($_parts);
|
}
|
||||||
// check name
|
} else {
|
||||||
if (isset($resource_name)) {
|
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
|
||||||
if ($_parts[$_parts_count-1] != $_resourcename_parts) {
|
$_parts_count = count($_parts);
|
||||||
continue;
|
// check name
|
||||||
}
|
if (isset($resource_name)) {
|
||||||
|
if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
// check compile id
|
}
|
||||||
if (isset($_compile_id) && (!isset($_parts[$_parts_count-2 - $_compile_id_offset]) || $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id)) {
|
// check compile id
|
||||||
|
if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// check cache id
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
// count of cache id parts
|
||||||
|
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
|
||||||
|
if ($_parts_count < $_cache_id_parts_count) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check cache id
|
for ($i = 0; $i < $_cache_id_parts_count; $i ++) {
|
||||||
if (isset($_cache_id)) {
|
if ($_parts[$i] != $_cache_id_parts[$i]) {
|
||||||
// count of cache id parts
|
continue 2;
|
||||||
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
|
|
||||||
if ($_parts_count < $_cache_id_parts_count) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for ($i = 0; $i < $_cache_id_parts_count; $i++) {
|
|
||||||
if ($_parts[$i] != $_cache_id_parts[$i]) continue 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// expired ?
|
}
|
||||||
if (isset($exp_time)) {
|
// expired ?
|
||||||
if ($exp_time < 0) {
|
if (isset($exp_time)) {
|
||||||
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
if ($exp_time < 0) {
|
||||||
if ($_time < (@filemtime($_file) + $match[1])) {
|
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
||||||
continue;
|
if ($_time < (@filemtime($_file) + $match[1])) {
|
||||||
}
|
continue;
|
||||||
} else {
|
}
|
||||||
if ($_time - @filemtime($_file) < $exp_time) {
|
} else {
|
||||||
continue;
|
if ($_time - @filemtime($_file) < $exp_time) {
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return $_count;
|
||||||
* Check is cache is locked for this template
|
}
|
||||||
*
|
|
||||||
* @param Smarty $smarty Smarty object
|
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
|
||||||
* @return booelan true or false if cache is locked
|
|
||||||
*/
|
|
||||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
|
||||||
{
|
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
|
||||||
clearstatcache(true, $cached->lock_id);
|
|
||||||
} else {
|
|
||||||
clearstatcache();
|
|
||||||
}
|
|
||||||
$t = @filemtime($cached->lock_id);
|
|
||||||
|
|
||||||
return $t && (time() - $t < $smarty->locking_timeout);
|
/**
|
||||||
|
* Check is cache is locked for this template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty Smarty object
|
||||||
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
|
*
|
||||||
|
* @return boolean true or false if cache is locked
|
||||||
|
*/
|
||||||
|
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
|
{
|
||||||
|
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||||
|
clearstatcache(true, $cached->lock_id);
|
||||||
|
} else {
|
||||||
|
clearstatcache();
|
||||||
}
|
}
|
||||||
|
$t = @filemtime($cached->lock_id);
|
||||||
|
|
||||||
/**
|
return $t && (time() - $t < $smarty->locking_timeout);
|
||||||
* Lock cache for this template
|
}
|
||||||
*
|
|
||||||
* @param Smarty $smarty Smarty object
|
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
|
||||||
*/
|
|
||||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
|
||||||
{
|
|
||||||
$cached->is_locked = true;
|
|
||||||
touch($cached->lock_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlock cache for this template
|
* Lock cache for this template
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
*/
|
*
|
||||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
* @return bool|void
|
||||||
{
|
*/
|
||||||
$cached->is_locked = false;
|
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
@unlink($cached->lock_id);
|
{
|
||||||
}
|
$cached->is_locked = true;
|
||||||
|
touch($cached->lock_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock cache for this template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty Smarty object
|
||||||
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
|
*
|
||||||
|
* @return bool|void
|
||||||
|
*/
|
||||||
|
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
|
{
|
||||||
|
$cached->is_locked = false;
|
||||||
|
@unlink($cached->lock_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue