mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- fixed variable filenames in {include_php} and {insert}
This commit is contained in:
@@ -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
|
||||
|
@@ -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,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;
|
||||
}
|
||||
|
@@ -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 . '"');
|
||||
}
|
||||
|
Reference in New Issue
Block a user