00001 <?php
00018 function smarty_core_get_php_resource(&$params, &$smarty)
00019 {
00020
00021 $params['resource_base_path'] = $smarty->trusted_dir;
00022 $smarty->_parse_resource_name($params, $smarty);
00023
00024
00025
00026
00027
00028 if ($params['resource_type'] == 'file') {
00029 $_readable = false;
00030 if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
00031 $_readable = true;
00032 } else {
00033
00034 $_params = array('file_path' => $params['resource_name']);
00035 require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
00036 if(smarty_core_get_include_path($_params, $smarty)) {
00037 $_include_path = $_params['new_file_path'];
00038 $_readable = true;
00039 }
00040 }
00041 } else if ($params['resource_type'] != 'file') {
00042 $_template_source = null;
00043 $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
00044 && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
00045 array($params['resource_name'], &$_template_source, &$smarty));
00046 }
00047
00048
00049
00050
00051 if (method_exists($smarty, '_syntax_error')) {
00052 $_error_funcc = '_syntax_error';
00053 } else {
00054 $_error_funcc = 'trigger_error';
00055 }
00056
00057 if ($_readable) {
00058 if ($smarty->security) {
00059 require_once(SMARTY_CORE_DIR . 'core.is_trusted.php');
00060 if (!smarty_core_is_trusted($params, $smarty)) {
00061 $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
00062 return false;
00063 }
00064 }
00065 } else {
00066 $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
00067 return false;
00068 }
00069
00070 if ($params['resource_type'] == 'file') {
00071 $params['php_resource'] = $params['resource_name'];
00072 } else {
00073 $params['php_resource'] = $_template_source;
00074 }
00075 return true;
00076 }
00077
00078
00079
00080 ?>