2003-05-08 20:21:16 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Smarty plugin
|
|
|
|
|
* @package Smarty
|
|
|
|
|
* @subpackage plugins
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* determines if a resource is secure or not.
|
|
|
|
|
*
|
|
|
|
|
* @param string $resource_type
|
|
|
|
|
* @param string $resource_name
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2003-10-11 08:55:53 +00:00
|
|
|
|
2003-05-08 20:21:16 +00:00
|
|
|
// $resource_type, $resource_name
|
2003-10-11 08:55:53 +00:00
|
|
|
|
2003-06-22 03:13:25 +00:00
|
|
|
function smarty_core_is_secure($params, &$smarty)
|
2003-05-08 20:21:16 +00:00
|
|
|
{
|
2003-06-22 03:13:25 +00:00
|
|
|
if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
|
2003-05-08 20:21:16 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($params['resource_type'] == 'file') {
|
2004-03-18 19:36:36 +00:00
|
|
|
$_rp = realpath($params['resource_name']);
|
|
|
|
|
if (isset($params['resource_base_path'])) {
|
|
|
|
|
foreach ((array)$params['resource_base_path'] as $curr_dir) {
|
|
|
|
|
if ( !empty($curr_dir) && is_readable ($curr_dir)) {
|
|
|
|
|
$_cd = realpath($curr_dir);
|
|
|
|
|
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
|
|
|
|
|
&& $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-12 22:19:32 +00:00
|
|
|
}
|
2003-06-22 03:13:25 +00:00
|
|
|
if (!empty($smarty->secure_dir)) {
|
|
|
|
|
foreach ((array)$smarty->secure_dir as $curr_dir) {
|
2003-05-08 20:21:16 +00:00
|
|
|
if ( !empty($curr_dir) && is_readable ($curr_dir)) {
|
2003-08-09 08:08:39 +00:00
|
|
|
$_cd = realpath($curr_dir);
|
|
|
|
|
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
|
|
|
|
|
&& $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
|
2004-03-18 19:36:36 +00:00
|
|
|
return true;
|
2003-05-08 20:21:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// resource is not on local file system
|
2004-03-18 19:36:36 +00:00
|
|
|
return call_user_func_array(
|
2003-06-22 03:13:25 +00:00
|
|
|
$smarty->_plugins['resource'][$params['resource_type']][0][2],
|
2004-02-24 00:10:55 +00:00
|
|
|
array($params['resource_name'], &$smarty));
|
2003-05-08 20:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
2004-03-18 19:36:36 +00:00
|
|
|
return false;
|
2003-05-08 20:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* vim: set expandtab: */
|
|
|
|
|
|
|
|
|
|
?>
|