smarty_security.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage Security
  7. * @author Uwe Tews
  8. */
  9. /**
  10. * This class does contain the security settings
  11. */
  12. class Smarty_Security {
  13. /**
  14. * This determines how Smarty handles "<?php ... ?>" tags in templates.
  15. * possible values:
  16. * <ul>
  17. * <li>SMARTY_PHP_PASSTHRU -> echo PHP tags as they are</li>
  18. * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
  19. * <li>SMARTY_PHP_REMOVE -> remove php tags</li>
  20. * <li>SMARTY_PHP_ALLOW -> execute php tags</li>
  21. * </ul>
  22. *
  23. * @var integer
  24. */
  25. public $php_handling = SMARTY_PHP_PASSTHRU;
  26. /**
  27. * This is the list of template directories that are considered secure.
  28. * One directory per array element.
  29. * $template_dir is in this list implicitly.
  30. *
  31. * @var array
  32. */
  33. public $secure_dir = array();
  34. /**
  35. * This is an array of directories where trusted php scripts reside.
  36. * {@link $security} is disabled during their inclusion/execution.
  37. *
  38. * @var array
  39. */
  40. public $trusted_dir = array();
  41. /**
  42. * This is an array of trusted static classes.
  43. *
  44. * If empty access to all static classes is allowed.
  45. * If set to 'none' none is allowed.
  46. * @var array
  47. */
  48. public $static_classes = array();
  49. /**
  50. * This is an array of trusted PHP functions.
  51. *
  52. * If empty all functions are allowed.
  53. * If set to 'none' none is allowed.
  54. * @var array
  55. */
  56. public $php_functions = array('isset', 'empty',
  57. 'count', 'sizeof','in_array', 'is_array','time','nl2br');
  58. /**
  59. * This is an array of trusted modifers.
  60. *
  61. * If empty all modifiers are allowed.
  62. * If set to 'none' none is allowed.
  63. * @var array
  64. */
  65. public $modifiers = array('escape','count');
  66. /**
  67. * This is an array of trusted streams.
  68. *
  69. * If empty all streams are allowed.
  70. * If set to 'none' none is allowed.
  71. * @var array
  72. */
  73. public $streams = array('file');
  74. /**
  75. + flag if constants can be accessed from template
  76. */
  77. public $allow_constants = true;
  78. /**
  79. + flag if super globals can be accessed from template
  80. */
  81. public $allow_super_globals = true;
  82. /**
  83. + flag if {php} tag can be executed
  84. */
  85. public $allow_php_tag = false;
  86. }
  87. ?>