示例#1
0
 /**
  * @return \Smarty
  * @throws \SmartyException
  */
 public static function getInstance()
 {
     $smarty = new \SmartyBC();
     $securityPolicy = new Smarty_Security($smarty);
     $securityPolicy->php_handling = \Smarty::PHP_ALLOW;
     $smarty->enableSecurity($securityPolicy);
     return $smarty;
 }
示例#2
0
$registry = new Registry();
$router = new Router($registry);
$registry['router'] = $router;
$registry['log'] = $log;
$router->setPath(site_path . 'controllers');
class My_Security_Policy extends Smarty_Security
{
    // disable all PHP functions
    public $php_functions = array();
    // remove PHP tags
    public $php_handling = Smarty::PHP_REMOVE;
    // allow everthing as modifier
    public $modifiers = array();
    public $trusted_dir = array();
    public $allow_php_tag = true;
    public function __construct($smarty)
    {
        parent::__construct($smarty);
        $this->secure_dir[] = dirname(__FILE__);
    }
}
$smarty = new SmartyBC();
$smarty->enableSecurity('My_Security_Policy');
$smarty->debugging = false;
//$smarty->allow_php_tag = true;
$smarty->caching = false;
//$smarty->cache_lifetime = 120;
$smarty->template_dir = site_path . "templates" . DIRSEP . $template_name . DIRSEP;
$smarty->config_dir = site_path . "configs" . DIRSEP;
$registry['smarty'] = $smarty;
$router->deligate();