51 if (!($compiler->smarty instanceof SmartyBC)) {
52 throw new SmartyException(
"{include_php} is deprecated, use SmartyBC class to enable");
59 $_smarty_tpl = $compiler->template;
61 eval(
'$_file = ' . $_attr[
'file'] .
';');
62 if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
65 if (isset($compiler->smarty->security_policy)) {
66 $_dir = $compiler->smarty->security_policy->trusted_dir;
68 $_dir = $compiler->smarty->trusted_dir;
71 foreach((array)$_dir as $_script_dir) {
72 $_script_dir = rtrim($_script_dir,
'/\\') . DS;
73 if (file_exists($_script_dir . $_file)) {
74 $_filepath = $_script_dir . $_file;
80 if ($_filepath ==
false) {
81 $compiler->trigger_template_error(
"{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno);
84 if (isset($compiler->smarty->security_policy)) {
85 $compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
88 if (isset($_attr[
'assign'])) {
90 $_assign = $_attr[
'assign'];
93 if (isset($_attr[
'once'])) {
94 if ($_attr[
'once'] ==
'false') {
99 if (isset($_assign)) {
100 return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>";
102 return "<?php include{$_once} ('{$_filepath}');?>\n";
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler)
Compiles code for the {include_php} tag.