| 1 | <?php |
| 2 | |
| 3 | function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) { |
| 4 | |
| 5 | global $db,$error,$node, $error_messages; |
| 6 | $add_template_id = preg_replace('/\.tpl$/', '', $tpl_name); |
| 7 | |
| 8 | if (!is_numeric($add_template_id)) { |
| 9 | $error = $error_messages['NOT_NUMERIC']; |
| 10 | return false; |
| 11 | } |
| 12 | |
| 13 | /* |
| 14 | //logging of every template for security reasons FIXME!!! TODO!!! |
| 15 | $params['node_creator'] = UBIK_ID; |
| 16 | $params['node_parent'] = 2029360; |
| 17 | $params['node_name'] = "addTemplate execute: node $add_template_id"; |
| 18 | $params['node_content'] = mysql_real_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> by user ".$_SESSION['user_name']); |
| 19 | nodes::addNode($params); |
| 20 | */ |
| 21 | |
| 22 | if(!($set=$db->query("select node_content from nodes where node_id='$add_template_id'"))) return false; |
| 23 | $set->next(); |
| 24 | // populating $tpl_source with actual template contents |
| 25 | $tpl_source = stripslashes($set->getString('node_content')); |
| 26 | // return true on success, false to generate failure notification |
| 27 | return true; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) |
| 32 | { |
| 33 | // do database call here to populate $tpl_timestamp |
| 34 | // with unix epoch time value of last template modification. |
| 35 | // This is used to determine if recompile is necessary. |
| 36 | $tpl_timestamp = time(); // this example will always recompile! FIXME!!! TODO!!! |
| 37 | // return true on success, false to generate failure notification |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | function db_get_secure($tpl_name, &$smarty_obj) |
| 42 | { |
| 43 | // assume all templates are secure |
| 44 | return true; //FIXME!!! TODO!!! |
| 45 | } |
| 46 | |
| 47 | function db_get_trusted($tpl_name, &$smarty_obj) |
| 48 | { |
| 49 | // not used for templates |
| 50 | } |
| 51 | |
| 52 | // register the resource name "kyberia" |
| 53 | $smarty->register_resource('kyberia', array('db_get_template', |
| 54 | 'db_get_timestamp', |
| 55 | 'db_get_secure', |
| 56 | 'db_get_trusted')); |
| 57 | |