60 if (function_exists(
'set_time_limit')) {
61 @set_time_limit($time_limit);
63 $smarty->force_compile = $force_compile;
68 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
69 $_compile =
new RecursiveIteratorIterator($_compileDirs);
70 foreach ($_compile as $_fileinfo) {
71 $_file = $_fileinfo->getFilename();
72 if (substr(basename($_fileinfo->getPathname()), 0, 1) ==
'.' || strpos($_file,
'.svn') !==
false) {
75 if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
78 if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
79 $_template_file = $_file;
81 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
83 echo
'<br>', $_dir,
'---', $_template_file;
85 $_start_time = microtime(
true);
87 $_tpl = $smarty->
createTemplate($_template_file, null, null, null,
false);
88 if ($_tpl->mustCompile()) {
89 $_tpl->compileTemplateSource();
91 echo
' compiled in ', microtime(
true) - $_start_time,
' seconds';
94 echo
' is up to date';
98 catch (Exception $e) {
99 echo
'Error: ', $e->getMessage(),
"<br><br>";
103 $smarty->template_objects = array();
104 $_tpl->smarty->template_objects = array();
106 if ($max_errors !== null && $_error_count == $max_errors) {
107 echo
'<br><br>too many errors';
130 if (function_exists(
'set_time_limit')) {
131 @set_time_limit($time_limit);
133 $smarty->force_compile = $force_compile;
138 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
139 $_compile =
new RecursiveIteratorIterator($_compileDirs);
140 foreach ($_compile as $_fileinfo) {
141 $_file = $_fileinfo->getFilename();
142 if (substr(basename($_fileinfo->getPathname()), 0, 1) ==
'.' || strpos($_file,
'.svn') !==
false) {
145 if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
148 if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
149 $_config_file = $_file;
151 $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
153 echo
'<br>', $_dir,
'---', $_config_file;
155 $_start_time = microtime(
true);
157 $_config =
new Smarty_Internal_Config($_config_file, $smarty);
158 if ($_config->mustCompile()) {
159 $_config->compileConfigSource();
161 echo
' compiled in ', microtime(
true) - $_start_time,
' seconds';
164 echo
' is up to date';
168 catch (Exception $e) {
169 echo
'Error: ', $e->getMessage(),
"<br><br>";
172 if ($max_errors !== null && $_error_count == $max_errors) {
173 echo
'<br><br>too many errors';
195 if ($_compile_dir ==
'/') {
198 $_compile_id = isset($compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $compile_id) : null;
199 $_dir_sep = $smarty->use_sub_dirs ?
'/' :
'^';
200 if (isset($resource_name)) {
201 $_save_stat = $smarty->caching;
202 $smarty->caching =
false;
203 $tpl =
new $smarty->template_class($resource_name, $smarty);
204 $smarty->caching = $_save_stat;
208 if ($smarty->allow_ambiguous_resources) {
209 $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
211 $_templateId = $smarty->joined_template_dir .
'#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
213 if (isset($_templateId[150])) {
214 $_templateId = sha1($_templateId);
216 unset($smarty->template_objects[$_templateId]);
218 if ($tpl->source->exists) {
219 $_resource_part_1 = basename(str_replace(
'^',
'/', $tpl->compiled->filepath));
220 $_resource_part_1_length = strlen($_resource_part_1);
225 $_resource_part_2 = str_replace(
'.php',
'.cache.php', $_resource_part_1);
226 $_resource_part_2_length = strlen($_resource_part_2);
228 $_dir = $_compile_dir;
229 if ($smarty->use_sub_dirs && isset($_compile_id)) {
230 $_dir .= $_compile_id . $_dir_sep;
232 if (isset($_compile_id)) {
233 $_compile_id_part = str_replace(
'\\',
'/', $_compile_dir . $_compile_id . $_dir_sep);
234 $_compile_id_part_length = strlen($_compile_id_part);
238 $_compileDirs =
new RecursiveDirectoryIterator($_dir);
241 catch (Exception $e) {
244 $_compile =
new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
245 foreach ($_compile as $_file) {
246 if (substr(basename($_file->getPathname()), 0, 1) ==
'.' || strpos($_file,
'.svn') !==
false) {
250 $_filepath = str_replace(
'\\',
'/', (
string) $_file);
252 if ($_file->isDir()) {
253 if (!$_compile->isDot()) {
255 @rmdir($_file->getPathname());
259 if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
260 && (!isset($resource_name)
261 || (isset($_filepath[$_resource_part_1_length])
262 && substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == 0)
263 || (isset($_filepath[$_resource_part_2_length])
264 && substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == 0))
266 if (isset($exp_time)) {
267 if (time() - @filemtime($_filepath) >= $exp_time) {
275 if ($unlink && @unlink($_filepath)) {
298 $template->smarty->get_used_tags =
true;
301 return $template->used_tags;