2 function addTemplate() {
4 global $db,$error,$node, $error_messages;
5 $add_template_id = $_POST['add_template_id'];
7 if (!is_numeric($add_template_id)) {
8 $error = $error_messages['NOT_NUMERIC'];
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);
19 $set=$db->query("select node_content from nodes where node_id='$add_template_id'");
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);
26 chown(OWN_TEMPLATE_DIR.$add_template_id.".tpl","wwwedit"); // XXX WTF
27 $q="update nodes set external_link = 'template://$add_template_id' where node_id='".$add_template_id."'";