template_dir = $templates_folder; $smarty->config_dir = $templates_folder.'/config/'; $smarty->compile_dir = dirname(__FILE__).'/../temp/'; $smarty->cache_dir = dirname(__FILE__).'/../temp/'; $smarty->compile_id = md5($templates_folder); if ($escape_html == true) { $smarty->register_modifier('unescape', 'smarty_modifier_unescape'); $smarty->register_postfilter('smarty_postfilter_inoculate'); } return $smarty; } function htmlspecialchars_recursive($var, $quote_style) { if(is_array($var)) { $ret = array(); foreach($var as $key => $val) { $ret[$key] = htmlspecialchars_recursive($val, $quote_style); } } elseif(is_string($var)) { $ret = htmlspecialchars($var, ENT_QUOTES); } else { $ret = $var; } return $ret; } function smarty_postfilter_inoculate($tpl_output, &$smarty) { if(!empty($smarty->_tpl_vars)) { foreach($smarty->_tpl_vars as $key => $value) { $smarty->_tpl_vars[$key] = htmlspecialchars_recursive($value, ENT_QUOTES); } } return $tpl_output; } function smarty_modifier_unescape($string) { return htmlspecialchars_decode($string, ENT_QUOTES); } ?>