Timbalu wrote:The only secure way to pass by the mentioned problem having 2k11 as defaultTemplate and using some other template as (main)template, with the case of (staticpage) tpl fallback to2k11, is to add it to cores functions_smarty.inc
Code: Select all
$serendipity['smarty']->register_modifier('html5time', 'serendipity_smarty_html5time');
and
Code: Select all
function serendipity_smarty_html5time($timestamp) {
return date("c", $timestamp);
}
and get rid of it in 2k11's config.
In the meantime I know what is happening, and why I get a
new "Cannot redeclare ..." fatal error, apart from using 2k11 as defaultTemplate and the upper mentioned "not allowed..." error. (This "not allowed" error has to get investigated still, though we changed the security by Garvin some time ago, which I think came into after I ran those tests.)
If you have 2k11 as your personal (not! default) template and copy/rename it to i.e. "my2k11" and then change to that template in the styles section, you get this error stopping the system to halt, while still having 2k11/config alive and switching to new my2k11/config. You need to reload that page to avoid parsing both configs. This could be a problem to John Doe going that way. This will happen for every copied template using own functions (and register them to smarty).
So here is my solution. We could either say:
Do not include functions and register things in configs directly. Use
Code: Select all
require_once or include_once('addCode.php');
or check if the function_exists first and use it that way i.e.:
Code: Select all
if (!function_exists('serendipity_smarty_html5time')) {
function serendipity_smarty_html5time($timestamp) { return date("c", $timestamp); }
if( defined('Smarty::SMARTY_VERSION') ) {
$serendipity['smarty']->registerPlugin('modifier', 'serendipity_html5time', 'serendipity_smarty_html5time');
} else {
// old Smarty 2 syntax
$serendipity['smarty']->register_modifier('serendipity_html5time', 'serendipity_smarty_html5time');
}
}
What do you think?