- fixed variable filenames in {include_php} and {insert}

This commit is contained in:
Uwe.Tews
2009-11-12 17:20:42 +00:00
parent 7af23e23b6
commit 55b2d90fb8
3 changed files with 19 additions and 15 deletions

View File

@@ -1,3 +1,6 @@
11/12/2009
- fixed variable filenames in {include_php} and {insert}
11/11/2009
- fixed {foreachelse}, {forelse}, {sectionelse} compiled code at nocache variables
- removed checking for reserved variables

View File

@@ -29,22 +29,23 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase {
$_attr = $this->_get_attributes($args);
$_output = '<?php ';
// save posible attributes
$_file = $_attr['file'];
$_file = realpath(trim($_file, "'"));
if ($this->smarty->security) {
$this->smarty->security_handler->isTrustedPHPDir($_file);
$_smarty_tpl = $compiler->template;
eval('$_file = ' . $_attr['file'] . ';');
$_file = realpath($_file);
if ($this->compiler->smarty->security) {
$this->compiler->smarty->security_handler->isTrustedPHPDir($_file);
}
if ($_file === false) {
$this->compiler->trigger_template_error('include_php: file "' . $_attr['file'] . '" is not readable');
}
if ($this->smarty->security) {
$this->smarty->security_handler->isTrustedPHPDir($_file);
if ($this->compiler->smarty->security) {
$this->compiler->smarty->security_handler->isTrustedPHPDir($_file);
}
if (isset($_attr['assign'])) {
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr['assign'];
@@ -60,7 +61,6 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase {
if (isset($_assign)) {
$_output .= 'ob_start(); include' . $_once . ' (\'' . $_file . '\'); $_smarty_tpl->assign(' . $_assign . ',ob_get_contents()); ob_end_clean();?>';
} else {
$this->compiler->has_output = true;
$_output .= 'include' . $_once . ' (\'' . $_file . '\');?>';
}
return $_output;

View File

@@ -41,7 +41,8 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
}
if (isset($_attr['script'])) {
// script which must be included
$_script = $_attr['script'];
$_smarty_tpl = $compiler->template;
eval('$_script = ' . $_attr['script'] . ';');
if (!file_exists($_script)) {
$this->compiler->trigger_template_error('missing file "' . $_script . '"');
}