Skip to content

Commit

Permalink
- optimization replace internal Smarty::$ds property by DIRECTORY_SEP…
Browse files Browse the repository at this point in the history
…ARATOR
  • Loading branch information
uwetews committed Oct 26, 2017
1 parent 570bc41 commit 5d8cd94
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions libs/sysplugins/smarty_internal_compile_include_php.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @subpackage Compiler
* @author Uwe Tews
*/

/**
* Smarty Internal Plugin Compile Insert Class
*
Expand Down Expand Up @@ -57,7 +56,6 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
}
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);

/** @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
Expand All @@ -74,8 +72,8 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
$_dir = $compiler->smarty->trusted_dir;
}
if (!empty($_dir)) {
foreach ((array) $_dir as $_script_dir) {
$_path = $compiler->smarty->_realpath($_script_dir . $compiler->smarty->ds . $_file, true);
foreach ((array)$_dir as $_script_dir) {
$_path = $compiler->smarty->_realpath($_script_dir . DIRECTORY_SEPARATOR . $_file, true);
if (file_exists($_path)) {
$_filepath = $_path;
break;
Expand All @@ -86,11 +84,9 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
if ($_filepath == false) {
$compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
}

if (isset($compiler->smarty->security_policy)) {
$compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
}

if (isset($_attr[ 'assign' ])) {
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr[ 'assign' ];
Expand All @@ -101,7 +97,6 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
$_once = '';
}
}

if (isset($_assign)) {
return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
} else {
Expand Down

0 comments on commit 5d8cd94

Please sign in to comment.