Редакция 2 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 87 | ||
---|---|---|---|
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 secure or not.
|
9 | * determines if a resource is secure 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_secure($params, &$smarty) |
18 | function smarty_core_is_secure($params, &$smarty) |
19 | {
|
19 | {
|
20 | if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) { |
20 | if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) { |
21 | return true; |
21 | return true; |
22 | }
|
22 | }
|
23 | 23 | ||
24 | if ($params['resource_type'] == 'file') { |
24 | if ($params['resource_type'] == 'file') { |
25 | $_rp = realpath($params['resource_name']); |
25 | $_rp = realpath($params['resource_name']); |
26 | if (isset($params['resource_base_path'])) { |
26 | if (isset($params['resource_base_path'])) { |
27 | foreach ((array)$params['resource_base_path'] as $curr_dir) { |
27 | foreach ((array)$params['resource_base_path'] as $curr_dir) { |
28 | if ( ($_cd = realpath($curr_dir)) !== false && |
28 | if ( ($_cd = realpath($curr_dir)) !== false && |
29 | strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
29 | strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
30 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { |
30 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { |
31 | return true; |
31 | return true; |
32 | }
|
32 | }
|
33 | }
|
33 | }
|
34 | }
|
34 | }
|
35 | if (!empty($smarty->secure_dir)) { |
35 | if (!empty($smarty->secure_dir)) { |
36 | foreach ((array)$smarty->secure_dir as $curr_dir) { |
36 | foreach ((array)$smarty->secure_dir as $curr_dir) { |
37 | if ( ($_cd = realpath($curr_dir)) !== false) { |
37 | if ( ($_cd = realpath($curr_dir)) !== false) { |
38 | if($_cd == $_rp) { |
38 | if($_cd == $_rp) { |
39 | return true; |
39 | return true; |
40 | } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
40 | } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
41 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { |
41 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { |
42 | return true; |
42 | return true; |
43 | }
|
43 | }
|
44 | }
|
44 | }
|
45 | }
|
45 | }
|
46 | }
|
46 | }
|
47 | } else { |
47 | } else { |
48 | // resource is not on local file system
|
48 | // resource is not on local file system
|
49 | return call_user_func_array( |
49 | return call_user_func_array( |
50 | $smarty->_plugins['resource'][$params['resource_type']][0][2], |
50 | $smarty->_plugins['resource'][$params['resource_type']][0][2], |
51 | array($params['resource_name'], &$smarty)); |
51 | array($params['resource_name'], &$smarty)); |
52 | }
|
52 | }
|
53 | 53 | ||
54 | return false; |
54 | return false; |
55 | }
|
55 | }
|
56 | 56 | ||
57 | /* vim: set expandtab: */
|
57 | /* vim: set expandtab: */
|
58 | 58 | ||
59 | ?>
|
59 | ?>
|
60 | 60 |