Automatically exported from code.google.com/p/planningalerts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.3 KiB

  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * determines if a resource is trusted or not
  9. *
  10. * @param string $resource_type
  11. * @param string $resource_name
  12. * @return boolean
  13. */
  14. // $resource_type, $resource_name
  15. function smarty_core_is_trusted($params, &$smarty)
  16. {
  17. $_smarty_trusted = false;
  18. if ($params['resource_type'] == 'file') {
  19. if (!empty($smarty->trusted_dir)) {
  20. $_rp = realpath($params['resource_name']);
  21. foreach ((array)$smarty->trusted_dir as $curr_dir) {
  22. if (!empty($curr_dir) && is_readable ($curr_dir)) {
  23. $_cd = realpath($curr_dir);
  24. if (strncmp($_rp, $_cd, strlen($_cd)) == 0
  25. && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
  26. $_smarty_trusted = true;
  27. break;
  28. }
  29. }
  30. }
  31. }
  32. } else {
  33. // resource is not on local file system
  34. $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
  35. array($params['resource_name'], $smarty));
  36. }
  37. return $_smarty_trusted;
  38. }
  39. /* vim: set expandtab: */
  40. ?>