Blame www/smarty/internals/core.is_trusted.php
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty plugin
|
|
Chris PeBenito |
696b41 |
* @package Smarty
|
|
Chris PeBenito |
696b41 |
* @subpackage plugins
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* determines if a resource is trusted or not
|
|
Chris PeBenito |
696b41 |
*
|
|
Chris PeBenito |
696b41 |
* @param string $resource_type
|
|
Chris PeBenito |
696b41 |
* @param string $resource_name
|
|
Chris PeBenito |
696b41 |
* @return boolean
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
// $resource_type, $resource_name
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
function smarty_core_is_trusted($params, &$smarty)
|
|
Chris PeBenito |
696b41 |
{
|
|
Chris PeBenito |
696b41 |
$_smarty_trusted = false;
|
|
Chris PeBenito |
696b41 |
if ($params['resource_type'] == 'file') {
|
|
Chris PeBenito |
696b41 |
if (!empty($smarty->trusted_dir)) {
|
|
Chris PeBenito |
696b41 |
$_rp = realpath($params['resource_name']);
|
|
Chris PeBenito |
696b41 |
foreach ((array)$smarty->trusted_dir as $curr_dir) {
|
|
Chris PeBenito |
696b41 |
if (!empty($curr_dir) && is_readable ($curr_dir)) {
|
|
Chris PeBenito |
696b41 |
$_cd = realpath($curr_dir);
|
|
Chris PeBenito |
696b41 |
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
|
|
Chris PeBenito |
696b41 |
&& $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
|
|
Chris PeBenito |
696b41 |
$_smarty_trusted = true;
|
|
Chris PeBenito |
696b41 |
break;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
// resource is not on local file system
|
|
Chris PeBenito |
696b41 |
$_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
|
|
Chris PeBenito |
696b41 |
array($params['resource_name'], $smarty));
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
return $_smarty_trusted;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/* vim: set expandtab: */
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
?>
|