Commit | Line | Data |
---|---|---|
6a967e24 H |
1 | <?php |
2 | ||
3 | function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) { | |
4 | ||
5 | global $db,$error,$node, $error_messages; | |
4dd26acd | 6 | $add_template_id = preg_replace('/\.tpl$/', '', $tpl_name); |
6a967e24 H |
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"; | |
78f1a5f4 | 18 | $params['node_content'] = db_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> by user ".$_SESSION['user_name']); |
6a967e24 H |
19 | nodes::addNode($params); |
20 | */ | |
2b81c646 | 21 | /* |
6a967e24 H |
22 | if(!($set=$db->query("select node_content from nodes where node_id='$add_template_id'"))) return false; |
23 | $set->next(); | |
2b81c646 | 24 | */ |
6a967e24 | 25 | // populating $tpl_source with actual template contents |
2b81c646 | 26 | //$tpl_source = stripslashes($set->getString('node_content')); |
13826e4f | 27 | $tpl_source = nodes::getNodeById($add_template_id,empty($_SESSION['user_id']) ? "" : $_SESSION['user_id']); |
2b81c646 | 28 | $tpl_source = $tpl_source['node_content']; |
6a967e24 H |
29 | // return true on success, false to generate failure notification |
30 | return true; | |
31 | } | |
32 | ||
33 | ||
34 | function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) | |
35 | { | |
36 | // do database call here to populate $tpl_timestamp | |
37 | // with unix epoch time value of last template modification. | |
38 | // This is used to determine if recompile is necessary. | |
2b81c646 | 39 | $recompile = 100; //recompile every N seconds |
c0aaf671 | 40 | $tpl_timestamp = floor(time()/$recompile)*$recompile; |
41 | // this example will recompile even unchanged templates! XXX!!! FIXME!!! TODO!!! | |
6a967e24 H |
42 | // return true on success, false to generate failure notification |
43 | return true; | |
44 | } | |
45 | ||
46 | function db_get_secure($tpl_name, &$smarty_obj) | |
47 | { | |
48 | // assume all templates are secure | |
49 | return true; //FIXME!!! TODO!!! | |
50 | } | |
51 | ||
52 | function db_get_trusted($tpl_name, &$smarty_obj) | |
53 | { | |
54 | // not used for templates | |
55 | } | |
56 | ||
57 | // register the resource name "kyberia" | |
58 | $smarty->register_resource('kyberia', array('db_get_template', | |
59 | 'db_get_timestamp', | |
60 | 'db_get_secure', | |
61 | 'db_get_trusted')); | |
62 |