| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: | class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase | 
| 18: | { | 
| 19: |  | 
| 20: |  | 
| 21: |  | 
| 22: |  | 
| 23: |  | 
| 24: |  | 
| 25: | public $required_attributes = array('file'); | 
| 26: |  | 
| 27: |  | 
| 28: |  | 
| 29: |  | 
| 30: |  | 
| 31: |  | 
| 32: |  | 
| 33: | public $shorttag_order = array('file'); | 
| 34: |  | 
| 35: |  | 
| 36: |  | 
| 37: |  | 
| 38: |  | 
| 39: |  | 
| 40: |  | 
| 41: | public $optional_attributes = array('once', 'assign'); | 
| 42: |  | 
| 43: |  | 
| 44: |  | 
| 45: |  | 
| 46: |  | 
| 47: |  | 
| 48: |  | 
| 49: |  | 
| 50: |  | 
| 51: |  | 
| 52: |  | 
| 53: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) | 
| 54: | { | 
| 55: | if (!($compiler->smarty instanceof SmartyBC)) { | 
| 56: | throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable"); | 
| 57: | } | 
| 58: |  | 
| 59: | $_attr = $this->getAttributes($compiler, $args); | 
| 60: |  | 
| 61: |  | 
| 62: |  | 
| 63: |  | 
| 64: |  | 
| 65: |  | 
| 66: | $_smarty_tpl = $compiler->template; | 
| 67: | $_filepath = false; | 
| 68: | $_file = null; | 
| 69: | eval('$_file = @' . $_attr[ 'file' ] . ';'); | 
| 70: | if (!isset($compiler->smarty->security_policy) && file_exists($_file)) { | 
| 71: | $_filepath = $compiler->smarty->_realpath($_file, true); | 
| 72: | } else { | 
| 73: | if (isset($compiler->smarty->security_policy)) { | 
| 74: | $_dir = $compiler->smarty->security_policy->trusted_dir; | 
| 75: | } else { | 
| 76: | $_dir = $compiler->smarty->trusted_dir; | 
| 77: | } | 
| 78: | if (!empty($_dir)) { | 
| 79: | foreach ((array)$_dir as $_script_dir) { | 
| 80: | $_path = $compiler->smarty->_realpath($_script_dir . DIRECTORY_SEPARATOR . $_file, true); | 
| 81: | if (file_exists($_path)) { | 
| 82: | $_filepath = $_path; | 
| 83: | break; | 
| 84: | } | 
| 85: | } | 
| 86: | } | 
| 87: | } | 
| 88: | if ($_filepath === false) { | 
| 89: | $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true); | 
| 90: | } | 
| 91: | if (isset($compiler->smarty->security_policy)) { | 
| 92: | $compiler->smarty->security_policy->isTrustedPHPDir($_filepath); | 
| 93: | } | 
| 94: | if (isset($_attr[ 'assign' ])) { | 
| 95: |  | 
| 96: | $_assign = $_attr[ 'assign' ]; | 
| 97: | } | 
| 98: | $_once = '_once'; | 
| 99: | if (isset($_attr[ 'once' ])) { | 
| 100: | if ($_attr[ 'once' ] === 'false') { | 
| 101: | $_once = ''; | 
| 102: | } | 
| 103: | } | 
| 104: | if (isset($_assign)) { | 
| 105: | return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>"; | 
| 106: | } else { | 
| 107: | return "<?php include{$_once} ('{$_filepath}');?>\n"; | 
| 108: | } | 
| 109: | } | 
| 110: | } | 
| 111: |  |