51ff3226 |
1 | <?php |
2 | function addTemplate() { |
3 | |
4 | global $db,$error,$node, $error_messages; |
5 | $add_template_id = $_POST['add_template_id']; |
6 | |
7 | if (!is_numeric($add_template_id)) { |
8 | $error = $error_messages['NOT_NUMERIC']; |
9 | return false; |
10 | } |
11 | |
12 | //logging of every template for security reasons |
13 | $params['node_creator'] = UBIK_ID; |
14 | $params['node_parent'] = 2029360; |
15 | $params['node_name'] = "addTemplate execute: node $add_template_id"; |
16 | $params['node_content'] = mysql_real_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> by user ".$_SESSION['user_name']); |
17 | nodes::addNode($params); |
18 | |
19 | $set=$db->query("select node_content from nodes where node_id='$add_template_id'"); |
20 | $set->next(); |
21 | $node_content = stripslashes($set->getString('node_content')); |
22 | $template_id = $node['template_id']; |
23 | $fp = fopen (OWN_TEMPLATE_DIR.$add_template_id.".tpl", "w+"); |
24 | fwrite($fp,$node_content); |
25 | fclose($fp); |
f657368b |
26 | chown(OWN_TEMPLATE_DIR.$add_template_id.".tpl","wwwedit"); // XXX WTF |
51ff3226 |
27 | $q="update nodes set external_link = 'template://$add_template_id' where node_id='".$add_template_id."'"; |
28 | $db->query($q); |
29 | |
30 | return true; |
31 | } |
32 | |
33 | ?> |