X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Finc%2Fsmarty%2Fresource.kyberia.php;h=57f687b7f3afd2f4f6c4c0bb386be3d66298b856;hb=HEAD;hp=3a08f08e1b4bfdbedc888278862a3254a0352139;hpb=6a967e24d43f3d23244c21104e6a3f09d5923cb9;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/inc/smarty/resource.kyberia.php b/wwwroot/inc/smarty/resource.kyberia.php index 3a08f08..57f687b 100644 --- a/wwwroot/inc/smarty/resource.kyberia.php +++ b/wwwroot/inc/smarty/resource.kyberia.php @@ -3,28 +3,28 @@ function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) { global $db,$error,$node, $error_messages; - $add_template_id = $tpl_name; - - if (!is_numeric($add_template_id)) { - $error = $error_messages['NOT_NUMERIC']; - return false; + $template_id = preg_replace('/\.tpl$/', '', $tpl_name); + + //from now on module names need not to be numeric! + if (!is_numeric($template_id)) { + $template_id=nodes::getNodeIdByName($tpl_name); + if (!is_numeric($template_id)) { + $error = $error_messages['NOT_NUMERIC']; + return false; + } } - /* - //logging of every template for security reasons FIXME!!! TODO!!! - $params['node_creator'] = UBIK_ID; - $params['node_parent'] = 2029360; - $params['node_name'] = "addTemplate execute: node $add_template_id"; - $params['node_content'] = mysql_real_escape_string("addTemplate execute: node $add_template_id by user ".$_SESSION['user_name']); - nodes::addNode($params); - */ - - if(!($set=$db->query("select node_content from nodes where node_id='$add_template_id'"))) return false; - $set->next(); - // populating $tpl_source with actual template contents - $tpl_source = stripslashes($set->getString('node_content')); + if (is_numeric($template_id)) { + $tpl_source = nodes::getNodeById($template_id,empty($_SESSION['user_id']) ? "" : $_SESSION['user_id']); + } + $template_name = $tpl_source['node_name']; + $template_signature = 'TEMPLATE /k/'.base_convert($template_id,10,36).' /id/'.$template_id.' ['.$template_name.']'; + $tpl_source = "\n\n\n\n". + $tpl_source['node_content']. + "\n\n\n\n"; + // return true on success, false to generate failure notification - return true; + return (bool)$tpl_source; } @@ -33,7 +33,9 @@ function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) // do database call here to populate $tpl_timestamp // with unix epoch time value of last template modification. // This is used to determine if recompile is necessary. - $tpl_timestamp = time(); // this example will always recompile! FIXME!!! TODO!!! + $recompile = 10; //recompile every N seconds + $tpl_timestamp = floor(time()/$recompile)*$recompile; + // this example will recompile even unchanged templates! XXX!!! FIXME!!! TODO!!! // return true on success, false to generate failure notification return true; }