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) {
|
2004-04-12 12:20:43 +00:00
|
|
|
if ( ($_cd = realpath($curr_dir)) !== false &&
|
|
|
|
|
strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
2005-11-23 20:36:05 +00:00
|
|
|
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
|
2004-04-12 12:20:43 +00:00
|
|
|
return true;
|
2004-03-18 19:36:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
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) {
|
2005-08-03 12:44:39 +00:00
|
|
|
if ( ($_cd = realpath($curr_dir)) !== false) {
|
2005-08-17 15:27:40 +00:00
|
|
|
if($_cd == $_rp) {
|
2005-08-03 12:44:39 +00:00
|
|
|
return true;
|
2005-08-17 15:27:40 +00:00
|
|
|
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
2005-11-23 20:36:05 +00:00
|
|
|
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
|
2005-08-03 12:44:39 +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: */
|
|
|
|
|
|
|
|
|
|
?>
|