75 'in_array',
'is_array',
174 $this->smarty = $smarty;
187 if (isset($this->php_functions) && (empty($this->php_functions) || in_array($function_name, $this->php_functions))) {
191 $compiler->trigger_template_error(
"PHP function '{$function_name}' not allowed by security setting");
205 if (isset($this->static_classes) && (empty($this->static_classes) || in_array($class_name, $this->static_classes))) {
209 $compiler->trigger_template_error(
"access to static class '{$class_name}' not allowed by security setting");
223 if (isset($this->php_modifiers) && (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))) {
227 $compiler->trigger_template_error(
"modifier '{$modifier_name}' not allowed by security setting");
242 if (in_array($tag_name, array(
'assign',
'call',
'private_filter',
'private_block_plugin',
'private_function_plugin',
'private_object_block_function',
243 'private_object_function',
'private_registered_function',
'private_registered_block',
'private_special_variable',
'private_print_expression',
'private_modifier'))) {
247 if (empty($this->allowed_tags)) {
248 if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
251 $compiler->trigger_template_error(
"tag '{$tag_name}' disabled by security setting", $compiler->lex->taglineno);
253 }
else if (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
256 $compiler->trigger_template_error(
"tag '{$tag_name}' not allowed by security setting", $compiler->lex->taglineno);
272 if (in_array($modifier_name, array(
'default'))) {
276 if (empty($this->allowed_modifiers)) {
277 if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
280 $compiler->trigger_template_error(
"modifier '{$modifier_name}' disabled by security setting", $compiler->lex->taglineno);
282 }
else if (in_array($modifier_name, $this->allowed_modifiers) && !in_array($modifier_name, $this->disabled_modifiers)) {
285 $compiler->trigger_template_error(
"modifier '{$modifier_name}' not allowed by security setting", $compiler->lex->taglineno);
299 if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) {
303 throw new SmartyException(
"stream '{$stream_name}' not allowed by security setting");
323 if ((!$this->_template_dir || $this->_template_dir !==
$_template_dir)
324 || (!$this->_config_dir || $this->_config_dir !==
$_config_dir)
325 || (!empty($this->secure_dir) && (!$this->_secure_dir || $this->_secure_dir !== $this->secure_dir))
327 $this->_resource_dir = array();
330 $_secure = !empty($this->secure_dir);
337 $directory = realpath($directory);
338 $this->_resource_dir[$directory] =
true;
346 $directory = realpath($directory);
347 $this->_resource_dir[$directory] =
true;
354 foreach ((array) $this->secure_dir as $directory) {
355 $directory = realpath($directory);
356 $this->_resource_dir[$directory] =
true;
360 $_filepath = realpath($filepath);
361 $directory = dirname($_filepath);
362 $_directory = array();
365 $_directory[$directory] =
true;
367 if (isset($this->_resource_dir[$directory])) {
369 $this->_resource_dir = array_merge($this->_resource_dir, $_directory);
373 if (($pos = strrpos($directory, DS)) ===
false || !isset($directory[1])) {
377 $directory = substr($directory, 0, $pos);
381 throw new SmartyException(
"directory '{$_filepath}' not allowed by security setting");
397 $_uri = parse_url($uri);
398 if (!empty($_uri[
'scheme']) && !empty($_uri[
'host'])) {
399 $_uri = $_uri[
'scheme'] .
'://' . $_uri[
'host'];
400 foreach ($this->trusted_uri as $pattern) {
401 if (preg_match($pattern, $_uri)) {
407 throw new SmartyException(
"URI '{$uri}' not allowed by security setting");
419 if (empty($this->trusted_dir)) {
420 throw new SmartyException(
"directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
424 if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) {
425 $this->_php_resource_dir = array();
428 foreach ((array) $this->trusted_dir as $directory) {
429 $directory = realpath($directory);
430 $this->_php_resource_dir[$directory] =
true;
434 $_filepath = realpath($filepath);
435 $directory = dirname($_filepath);
436 $_directory = array();
439 $_directory[] = $directory;
441 if (isset($this->_php_resource_dir[$directory])) {
443 $this->_php_resource_dir = array_merge($this->_php_resource_dir, $_directory);
447 if (($pos = strrpos($directory, DS)) ===
false || !isset($directory[2])) {
451 $directory = substr($directory, 0, $pos);
454 throw new SmartyException(
"directory '{$_filepath}' not allowed by security setting");
isTrustedPhpModifier($modifier_name, $compiler)
Check if PHP modifier is trusted.
isTrustedPhpFunction($function_name, $compiler)
Check if PHP function is trusted.
isTrustedStaticClass($class_name, $compiler)
Check if static class is trusted.
isTrustedUri($uri)
Check if URI (e.g.
const PHP_PASSTHRU
modes for handling of "" tags in templates.
isTrustedStream($stream_name)
Check if stream is trusted.
This class does contain the security settings.
isTrustedTag($tag_name, $compiler)
Check if tag is trusted.
isTrustedResourceDir($filepath)
Check if directory of file resource is trusted.
isTrustedPHPDir($filepath)
Check if directory of file resource is trusted.
isTrustedModifier($modifier_name, $compiler)
Check if modifier plugin is trusted.