diff options
| author | Uwe.Tews <uwe.tews@localhost> | 2009-12-27 15:06:49 +0000 |
|---|---|---|
| committer | Uwe.Tews <uwe.tews@localhost> | 2009-12-27 15:06:49 +0000 |
| commit | 44dd7830ddef97f8a87f5637d191d805c7a61f51 (patch) | |
| tree | 3d9872233d250af86ef2e8fb9cde4b94a2b384cf /libs/sysplugins/smarty_internal_compile_include.php | |
| parent | 5f02276a2a0b9237c7801e5541ddf90ae5e5ed4f (diff) | |
| download | smarty-44dd7830ddef97f8a87f5637d191d805c7a61f51.tar.gz smarty-44dd7830ddef97f8a87f5637d191d805c7a61f51.tar.bz2 smarty-44dd7830ddef97f8a87f5637d191d805c7a61f51.zip | |
--- this is a major update with a couple of internal changes ---
- new config file lexer/parser (thanks to Thue Jnaus Kristensen)
- template lexer/parser fixes for PHP and {literal} handing (thanks to Thue Jnaus Kristensen)
- fix on registered plugins with different type but same name
- rewrite of plugin handling (optimized execution speed)
- closed a security hole regarding PHP code injection into cache files
- fixed bug in clear cache handling
- Renamed a couple of internal classes
- code cleanup for merging compiled templates
- couple of runtime optimizations (still not all done)
Diffstat (limited to 'libs/sysplugins/smarty_internal_compile_include.php')
| -rw-r--r-- | libs/sysplugins/smarty_internal_compile_include.php | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index c0a8fd92..933d719a 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -36,49 +36,17 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { eval("\$tmp = $include_file;"); if ($this->compiler->template->template_resource != $tmp) { $tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); - if ($tpl->usesCompiler() && $tpl->isExisting()) { - do { - $must_compile = false; - $prop = array(); - $compiled_tpl = $tpl->getCompiledTemplate(); - preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); - $compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); - // var_dump($matches, $compiled_tpl); - if (isset($matches[2])) { - $prop = unserialize($matches[2]); - foreach ($prop['file_dependency'] as $_file_to_check) { - If (is_file($_file_to_check[0])) { - $mtime = filemtime($_file_to_check[0]); - } else { - $tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); - if ($resource_type == 'file') { - $must_compile = true; // subtemplate no longer existing - break; - } - $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); - } - // If ($mtime != $_file_to_check[1]) { - If ($mtime > $_file_to_check[1]) { - $must_compile = true; - break; - } - } - if ($must_compile) { - // recompile - $tpl->compileTemplateSource(); - } - } - } while ($must_compile); - if (isset($prop['file_dependency'])) { - $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); - } - if (isset($prop['function'])) { - if (isset($compiler->template->properties['function'])) { - $compiler->template->properties['function'] = array_merge((array)$compiler->template->properties['function'], $prop['function']); - } else { - $compiler->template->properties['function'] = $prop['function']; - } - } + if ($this->compiler->template->caching) { + // needs code for cached page but no cache file + $tpl->caching = 9999; + } + if ($tpl->resource_object->usesCompiler && $tpl->isExisting()) { + // make sure that template is up to date and merge template properties + $tpl->renderTemplate(); + // get compiled code + $compiled_tpl = $tpl->getCompiledTemplate(); + // remove header code + $compiled_tpl = preg_replace('/(<\?php \/\*%%SmartyHeaderCode%%\*\/(.+?)\/\*\/%%SmartyHeaderCode%%\*\/\?>\n)/s', '', $compiled_tpl); $has_compiled_template = true; } } @@ -163,6 +131,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { } $_output .= "<?php unset(\$_template);?>"; return $_output; - } -} + } +} + ?> |
