$node_content=nodes::processContent($node_content);
- if ($node_system_access=='crypto') {
-
- require(INCLUDE_DIR.'crypto.inc');
-
- if ($_SESSION['crypto'][$node_parent]) {
- $key=$_SESSION['crypto'][$node_parent];
- }
- else {
- $key = substr(md5(uniqid(rand(), true)),0,8);
- }
-
- $node_content=crypto::crypto($node_content,$key);
-
-
-
- }
-
$params['node_name']=$node_name;
$params['template_id']=$template_id;
$params['node_parent']=$node_parent;
$params['node_creator']=$_SESSION['user_id'];
$params['node_content']=db_escape_string($node_content);
$params['external_link']=$external_link;
- nodes::addNode($params);
+ $node_id=nodes::addNode($params);
+
+ if (!$node_id) {
+ return false;
+ }
+
+ if ($_FILES['data_file']['tmp_name']) {
+ copy($_FILES['data_file']['tmp_name'], FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix");
+ symlink(FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix",FILE_DIR.'/'.$node_id);
+ }
+
+ //substitute @@@ token by a node_id of a newly created node
+ $nc=preg_replace('/@@@/',$node_id,$params['node_content']);
+ if ($nc!=$params['node_content']) {
+ $db->update("update nodes set node_content='$nc' where node_id=$node_id");
+ }
+
return true;
}
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
global $db,$error,$node, $error_messages;
- $add_template_id = preg_replace('/\.tpl$/', '', $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'] = db_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> 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'));
- $tpl_source = nodes::getNodeById($add_template_id,empty($_SESSION['user_id']) ? "" : $_SESSION['user_id']);
- $tpl_source = $tpl_source['node_content'];
+ if (is_numeric($template_id)) {
+ $tpl_source = nodes::getNodeById($template_id,empty($_SESSION['user_id']) ? "" : $_SESSION['user_id']);
+ }
+ $tpl_source = $tpl_source['node_content'];
+
// return true on success, false to generate failure notification
- return true;
+ return (bool)$tpl_source;
}