diff --git a/change_log.txt b/change_log.txt index 1ed5522e..35cb84dc 100644 --- a/change_log.txt +++ b/change_log.txt @@ -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 diff --git a/libs/sysplugins/smarty_internal_compile_include_php.php b/libs/sysplugins/smarty_internal_compile_include_php.php index 2709d7dd..96b3ebe9 100644 --- a/libs/sysplugins/smarty_internal_compile_include_php.php +++ b/libs/sysplugins/smarty_internal_compile_include_php.php @@ -29,22 +29,23 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase { $_attr = $this->_get_attributes($args); $_output = '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,8 +61,7 @@ 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 . '\'); ?>'; + $_output .= 'include' . $_once . ' (\'' . $_file . '\');?>'; } return $_output; } diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php index 765e8df2..9e1da87e 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/libs/sysplugins/smarty_internal_compile_insert.php @@ -22,11 +22,11 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { */ public function compile($args, $compiler) { - $this->compiler = $compiler; + $this->compiler = $compiler; $this->required_attributes = array('name'); $this->optional_attributes = array('_any'); // check and get attributes - $_attr = $this->_get_attributes($args); + $_attr = $this->_get_attributes($args); // this tag must not be cached $this->compiler->tag_nocache = true; @@ -35,13 +35,14 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { $_name = 'insert_' . trim($_attr['name'], "'\""); if (isset($_attr['assign'])) { // output will be stored in a smarty variable instead of beind displayed - $_assign = $_attr['assign']; + $_assign = $_attr['assign']; // create variable to make shure that the compiler knows about its nocache status - $this->compiler->template->tpl_vars[trim($_attr['assign'],"'")] = new Smarty_Variable(null,true); + $this->compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true); } 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 . '"'); }