Редакция 2 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 235 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * Smarty plugin
|
3 | * Smarty plugin
|
4 | * @package Smarty
|
4 | * @package Smarty
|
5 | * @subpackage plugins
|
5 | * @subpackage plugins
|
6 | */
|
6 | */
|
7 | 7 | ||
8 | /**
|
8 | /**
|
9 | * determines if a resource is trusted or not
|
9 | * determines if a resource is trusted or not
|
10 | *
|
10 | *
|
11 | * @param string $resource_type
|
11 | * @param string $resource_type
|
12 | * @param string $resource_name
|
12 | * @param string $resource_name
|
13 | * @return boolean
|
13 | * @return boolean
|
14 | */
|
14 | */
|
15 | 15 | ||
16 | // $resource_type, $resource_name
|
16 | // $resource_type, $resource_name
|
17 | 17 | ||
18 | function smarty_core_is_trusted($params, &$smarty) |
18 | function smarty_core_is_trusted($params, &$smarty) |
19 | {
|
19 | {
|
20 | $_smarty_trusted = false; |
20 | $_smarty_trusted = false; |
21 | if ($params['resource_type'] == 'file') { |
21 | if ($params['resource_type'] == 'file') { |
22 | if (!empty($smarty->trusted_dir)) { |
22 | if (!empty($smarty->trusted_dir)) { |
23 | $_rp = realpath($params['resource_name']); |
23 | $_rp = realpath($params['resource_name']); |
24 | foreach ((array)$smarty->trusted_dir as $curr_dir) { |
24 | foreach ((array)$smarty->trusted_dir as $curr_dir) { |
25 | if (!empty($curr_dir) && is_readable ($curr_dir)) { |
25 | if (!empty($curr_dir) && is_readable ($curr_dir)) { |
26 | $_cd = realpath($curr_dir); |
26 | $_cd = realpath($curr_dir); |
27 | if (strncmp($_rp, $_cd, strlen($_cd)) == 0 |
27 | if (strncmp($_rp, $_cd, strlen($_cd)) == 0 |
28 | && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { |
28 | && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { |
29 | $_smarty_trusted = true; |
29 | $_smarty_trusted = true; |
30 | break; |
30 | break; |
31 | }
|
31 | }
|
32 | }
|
32 | }
|
33 | }
|
33 | }
|
34 | }
|
34 | }
|
35 | 35 | ||
36 | } else { |
36 | } else { |
37 | // resource is not on local file system
|
37 | // resource is not on local file system
|
38 | $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], |
38 | $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], |
39 | array($params['resource_name'], $smarty)); |
39 | array($params['resource_name'], $smarty)); |
40 | }
|
40 | }
|
41 | 41 | ||
42 | return $_smarty_trusted; |
42 | return $_smarty_trusted; |
43 | }
|
43 | }
|
44 | 44 | ||
45 | /* vim: set expandtab: */
|
45 | /* vim: set expandtab: */
|
46 | 46 | ||
47 | ?>
|
47 | ?>
|
48 | 48 |