diff options
author | Wave <wave72@users.noreply.github.com> | 2015-12-20 10:20:36 +0100 |
---|---|---|
committer | Wave <wave72@users.noreply.github.com> | 2015-12-20 10:20:36 +0100 |
commit | 2aad4c2cf9c17a7532089aadfcc5feff6505ec74 (patch) | |
tree | 2082c8dc7ba090f610874b6e33b0f1092a2ff00c /library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php | |
parent | 474a1267d73c1dcf00678dd15ed4e0e37496473d (diff) | |
parent | e2692a4baaf031bd0d9c0893c3762637b1f6b201 (diff) | |
download | volse-hubzilla-2aad4c2cf9c17a7532089aadfcc5feff6505ec74.tar.gz volse-hubzilla-2aad4c2cf9c17a7532089aadfcc5feff6505ec74.tar.bz2 volse-hubzilla-2aad4c2cf9c17a7532089aadfcc5feff6505ec74.zip |
Merge pull request #4 from redmatrix/master
Merge master into dev branch
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php index 76f506c52..e7e62997c 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php @@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $required_attributes = array('file'); + /** * Attribute definition: Overwrites base class. * @@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('file'); + /** * Attribute definition: Overwrites base class. * @@ -41,13 +43,14 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase /** * Compiles code for the {include_php} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object * - * @throws SmartyException - * @return string compiled code + * @return string + * @throws \SmartyCompilerException + * @throws \SmartyException */ - public function compile($args, $compiler) + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) { if (!($compiler->smarty instanceof SmartyBC)) { throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable"); @@ -60,9 +63,10 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase */ $_smarty_tpl = $compiler->template; $_filepath = false; - eval('$_file = ' . $_attr['file'] . ';'); + $_file = null; + eval('$_file = @' . $_attr['file'] . ';'); if (!isset($compiler->smarty->security_policy) && file_exists($_file)) { - $_filepath = $_file; + $_filepath = $compiler->smarty->_realpath($_file, true); } else { if (isset($compiler->smarty->security_policy)) { $_dir = $compiler->smarty->security_policy->trusted_dir; @@ -71,16 +75,16 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase } if (!empty($_dir)) { foreach ((array) $_dir as $_script_dir) { - $_script_dir = rtrim($_script_dir, '/\\') . DS; - if (file_exists($_script_dir . $_file)) { - $_filepath = $_script_dir . $_file; + $_path = $compiler->smarty->_realpath($_script_dir . DS . $_file, true); + if (file_exists($_path)) { + $_filepath = $_path; break; } } } } if ($_filepath == false) { - $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno); + $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true); } if (isset($compiler->smarty->security_policy)) { @@ -99,7 +103,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase } if (isset($_assign)) { - return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>"; + return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>"; } else { return "<?php include{$_once} ('{$_filepath}');?>\n"; } |