Smarty_Security
This class does contain the security settings
- Full name:
\Smarty_Security
Properties
secure_dir
This is the list of template directories that are considered secure.
$template_dir is in this list implicitly.
trusted_dir
This is an array of directories where trusted php scripts reside.
{@link $security} is disabled during their inclusion/execution.
trusted_uri
List of regular expressions (PCRE) that include trusted URIs
trusted_constants
List of trusted constants names
static_classes
This is an array of trusted static classes.
If empty access to all static classes is allowed. If set to 'none' none is allowed.
trusted_static_methods
This is an nested array of trusted classes and static methods.
If empty access to all static classes and methods is allowed. Format: array ( 'class_1' => array('method_1', 'method_2'), // allowed methods listed 'class_2' => array(), // all methods of class allowed ) If set to null none is allowed.
trusted_static_properties
This is an array of trusted static properties.
If empty access to all static classes and properties is allowed. Format: array ( 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed 'class_2' => array(), // all properties of class allowed ) If set to null none is allowed.
php_functions
This is an array of trusted PHP functions.
If empty all functions are allowed. To disable all PHP functions set $php_functions = null.
php_modifiers
This is an array of trusted PHP modifiers.
If empty all modifiers are allowed. To disable all modifier set $php_modifiers = null.
allowed_tags
This is an array of allowed tags.
If empty no restriction by allowed_tags.
disabled_tags
This is an array of disabled tags.
If empty no restriction by disabled_tags.
allowed_modifiers
This is an array of allowed modifier plugins.
If empty no restriction by allowed_modifiers.
disabled_modifiers
This is an array of disabled modifier plugins.
If empty no restriction by disabled_modifiers.
disabled_special_smarty_vars
This is an array of disabled special $smarty variables.
streams
This is an array of trusted streams.
If empty all streams are allowed. To disable all streams set $streams = null.
allow_constants
- flag if constants can be accessed from template
allow_super_globals
- flag if super globals can be accessed from template
max_template_nesting
max template nesting level
_current_template_nesting
current template nesting level
_resource_dir
Cache for $resource_dir lookup
_template_dir
Cache for $template_dir lookup
_config_dir
Cache for $config_dir lookup
_secure_dir
Cache for $secure_dir lookup
_php_resource_dir
Cache for $php_resource_dir lookup
_trusted_dir
Cache for $trusted_dir lookup
_include_path_status
Cache for include path status
_include_dir
Cache for $_include_array lookup
Methods
__construct
Parameters:
Parameter | Type | Description |
---|---|---|
$smarty |
\Smarty |
isTrustedPhpFunction
Check if PHP function is trusted.
- Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Parameters:
Parameter | Type | Description |
---|---|---|
$function_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if function is trusted
isTrustedStaticClass
Check if static class is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$class_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if class is trusted
isTrustedStaticClassAccess
Check if static class method/property is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$class_name |
string | |
$params |
string | |
$compiler |
object | compiler object |
Return Value:
true if class method is trusted
isTrustedPhpModifier
Check if PHP modifier is trusted.
- Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Parameters:
Parameter | Type | Description |
---|---|---|
$modifier_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if modifier is trusted
isTrustedTag
Check if tag is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$tag_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if tag is trusted
isTrustedSpecialSmartyVar
Check if special $smarty variable is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$var_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if tag is trusted
isTrustedModifier
Check if modifier plugin is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$modifier_name |
string | |
$compiler |
object | compiler object |
Return Value:
true if tag is trusted
isTrustedConstant
Check if constants are enabled or trusted
Parameters:
Parameter | Type | Description |
---|---|---|
$const |
string | constant name |
$compiler |
object | compiler object |
isTrustedStream
Check if stream is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$stream_name |
string |
Return Value:
true if stream is trusted
Throws:
if stream is not trusted
isTrustedResourceDir
Check if directory of file resource is trusted.
Parameters:
Parameter | Type | Description |
---|---|---|
$filepath |
string | |
$isConfig |
null|bool |
Return Value:
true if directory is trusted
Throws:
if directory is not trusted
isTrustedUri
Check if URI (e.g. {fetch} or {html_image}) is trusted To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}".
So "http://username:password@hello.world.example.org:8080/some-path?some=query-string" is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}.
Parameters:
Parameter | Type | Description |
---|---|---|
$uri |
string |
Return Value:
true if URI is trusted
Throws:
if URI is not trusted
_updateResourceDir
Remove old directories and its sub folders, add new directories
Parameters:
Parameter | Type | Description |
---|---|---|
$oldDir |
array | |
$newDir |
array |
_checkDir
Check if file is inside a valid directory
Parameters:
Parameter | Type | Description |
---|---|---|
$filepath |
string | |
$dirs |
array | valid directories |
Throws:
enableSecurity
Loads security class and enables security
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$smarty |
\Smarty | |
$security_class |
string|\Smarty_Security | if a string is used, it must be class-name |
Return Value:
current Smarty instance for chaining
Throws:
when an invalid class name is provided
startTemplate
Start template processing
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
mixed |
Throws:
endTemplate
Exit template processing
registerCallBacks
Register callback functions call at start/end of template rendering
Parameters:
Parameter | Type | Description |
---|---|---|
$template |
\Smarty_Internal_Template |
Automatically generated on 2025-03-18