2 //funkcie na pridanie Re: alebo Re[x]: do nazvu (by Maniax)
3 function title_reply_callback($_matches) {return ($_matches[1].($_matches[2] + 1).$_matches[3]);}
4 function title_reply($_in) {
6 if (preg_match('/^Re[:[]/', $_in)) {
7 if (preg_match('/^Re[/', $_in))
8 return (preg_replace_callback('/^(Re[)(d*)(].*)$/', 'title_reply_callback', $_in));
9 else return (preg_replace('/^(Re)(:.*)$/', '1[2]2', $_in));
10 } else return ('Re: '.$_in);
16 global $db,$error,$node,$permissions,$types;
18 $node_content=$_POST['node_content'];
19 $node_parent=$_POST['node_parent'];
20 $template_id=$_POST['template_id'];
22 if (empty($template_id)) $template_id=4;
23 $node_type=$template_id;
25 if (strlen($node_name)<1){
26 // $error="node_name too short. please write some title";
31 $node_name=addslashes(strip_tags($_POST['node_name']));
32 $external_link=addslashes(strip_tags($_POST['external_link']));
34 if (!empty($_POST['node_chosen'])) {
35 $node_chosen=$_POST['node_chosen'];
37 if (count($node_chosen)>1) {
38 $error="please select only one node.";
41 $node_parent=addslashes($node_chosen['0']);
42 $q="select * from nodes where node_id='".$node_parent."'";
44 $p_set = $db->query($q);
46 $node_parent_name = $p_set->getString('node_name');
47 $node_parent_template = $p_set->getString('template_id');
52 $node_parent_name = $node['node_name'];
53 $node_parent_template = $node['template_id'];
57 if (empty($node_name)) {
59 if (empty($node_parent_name)){
60 $node_name=date("d.m.Y-G:i:s");
61 }elseif ($node_parent_template == "4"){
62 $node_name = title_reply($node_parent_name);
64 $node_name=date("d.m.Y-G:i:s");
69 if (empty($node_name)) {
70 $node_name=date("d.m.Y-G:i:s");
72 $parent_name=$node['node_name'];
74 $node_creator=$_SESSION['user_id'];
76 $node_system_access=$node['node_system_access'];
79 if (empty($node_system_access)) {
80 $node_system_access='public';
84 $node_external_access=$_POST['node_external_access'];
85 if (empty($node_external_access)) {
86 $node_external_access='yes';
90 if (empty($node_content)) {
92 $error=$error_messages['ADD_NO_CONTENT'];
96 if (is_numeric($_SESSION['mood_id'])) {
97 $node_content .= "<br><br><small>".$_SESSION['mood_content']."</small>";
100 $node_content=nodes::processContent($node_content);
102 if ($node_system_access=='crypto') {
105 require(INCLUDE_DIR.'crypto.inc');
107 if ($_SESSION['crypto'][$node_parent]) {
108 $key=$_SESSION['crypto'][$node_parent];
112 $key = substr(md5(uniqid(rand(), true)),0,8);
115 $node_content=crypto::crypto($node_content,$key);
118 //setting generated crypto password for viewing
119 if ($node_system_access=='crypto') {
121 $_SESSION['crypto'][$id]=$key;
126 $params['node_name']=$node_name;
127 $params['template_id']=$template_id;
129 $params['node_parent']=$node_parent;
130 $params['node_system_access']=$node_system_access;
131 $params['node_creator']=$_SESSION['user_id'];
132 $params['node_content']=$node_content;
133 $params['external_link']=$external_link;
134 nodes::addNode($params);